Class: Rubigraph::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/rubigraph.rb

Overview

Edge between Vertexes

Instance Method Summary collapse

Constructor Details

#initialize(from, to, id = nil) ⇒ Edge

create an Edge. from, to should be Vertex.



86
87
88
89
90
91
# File 'lib/rubigraph.rb', line 86

def initialize(from, to, id = nil)
  @id = id ?
    Rubigraph.call('ubigraph.new_edge_w_id', id, from.id, to.id) :
    Rubigraph.call('ubigraph.new_edge', from.id, to.id)
  raise 'Rubigraph::Edge.initialize: cannot create edge' if @id == -1
end

Instance Method Details

#arrow=(a) ⇒ Object



151
152
153
# File 'lib/rubigraph.rb', line 151

def arrow=(a)
  set_attribute('arrow', a)
end

#color=(c) ⇒ Object



109
110
111
# File 'lib/rubigraph.rb', line 109

def color=(c)
  set_attribute('color', c)
end

#colour=(c) ⇒ Object



113
114
115
# File 'lib/rubigraph.rb', line 113

def colour=(c)
  self.color=(c)
end

#fontcolor=(c) ⇒ Object



125
126
127
# File 'lib/rubigraph.rb', line 125

def fontcolor=(c)
  set_attribute('fontcolor', c)
end

#fontfamily=(f) ⇒ Object



129
130
131
132
# File 'lib/rubigraph.rb', line 129

def fontfamily=(f)
  # TODO: should assert 'Helvetica' | 'Times Roman'
  set_attribute('fontfamily', f)
end

#fontsize=(s) ⇒ Object



134
135
136
137
# File 'lib/rubigraph.rb', line 134

def fontsize=(s)
  # TODO: should assert 10, 12, 18. 24
  set_attribute('fontsize', s)
end

#label=(l) ⇒ Object



117
118
119
# File 'lib/rubigraph.rb', line 117

def label=(l)
  set_attribute('label', l)
end

#labelpos=(p) ⇒ Object



121
122
123
# File 'lib/rubigraph.rb', line 121

def labelpos=(p)
  set_attribute('labelpos', p)
end

#orientationweight=(o) ⇒ Object



143
144
145
# File 'lib/rubigraph.rb', line 143

def orientationweight=(o)
  set_attribute('orientationweight', o)
end

#removeObject



93
94
95
96
97
# File 'lib/rubigraph.rb', line 93

def remove
  if -1 == Rubigraph.call('ubigraph.remove_edge', @id)
    raise "Rubigraph::Edge#remove: cannot remove edge #{@id}"
  end
end

#set_attribute(att, value) ⇒ Object



99
100
101
# File 'lib/rubigraph.rb', line 99

def set_attribute(att, value)
  Rubigraph.call('ubigraph.set_edge_attribute', @id, att, value.to_s)
end

#set_attributes(attrs) ⇒ Object



103
104
105
106
107
# File 'lib/rubigraph.rb', line 103

def set_attributes(attrs)
  attrs.each do |k, v|
    Rubigraph.call('ubigraph.set_edge_attribute', @id, k, v.to_s)
  end
end

#showstrain=(s) ⇒ Object



155
156
157
# File 'lib/rubigraph.rb', line 155

def showstrain=(s)
  set_attribute('showstrain', s)
end

#strength=(s) ⇒ Object



139
140
141
# File 'lib/rubigraph.rb', line 139

def strength=(s)
  set_attribute('strength', s)
end

#width=(w) ⇒ Object



147
148
149
# File 'lib/rubigraph.rb', line 147

def width=(w)
  set_attribute('width', w)
end