Class: GraphML::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-graphml.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs, graph) ⇒ Edge

Returns a new instance of Edge.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby-graphml.rb', line 35

def initialize(attrs, graph)
  attrs.each do |key, val|
    if key == 'source'
      @source = val
    elsif key == 'target'
      @target = val
    end
  end
  @graph = graph
  source.out_edges << self
  target.in_edges << self
end

Instance Method Details

#sourceObject



48
49
50
# File 'lib/ruby-graphml.rb', line 48

def source
  @graph.nodes[@source]
end

#targetObject



52
53
54
# File 'lib/ruby-graphml.rb', line 52

def target
  @graph.nodes[@target]
end