Class: GraphML::Edge
- Inherits:
-
Object
- Object
- GraphML::Edge
- Defined in:
- lib/ruby-graphml.rb
Instance Method Summary collapse
-
#initialize(attrs, graph) ⇒ Edge
constructor
A new instance of Edge.
- #source ⇒ Object
- #target ⇒ Object
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
#source ⇒ Object
48 49 50 |
# File 'lib/ruby-graphml.rb', line 48 def source @graph.nodes[@source] end |
#target ⇒ Object
52 53 54 |
# File 'lib/ruby-graphml.rb', line 52 def target @graph.nodes[@target] end |