Class: RGL::GraphXML::MutableGraphParser

Inherits:
Object
  • Object
show all
Includes:
REXML::StreamListener
Defined in:
lib/rgl/graphxml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ MutableGraphParser

Returns a new instance of MutableGraphParser.



35
36
37
# File 'lib/rgl/graphxml.rb', line 35

def initialize (graph)
  @graph = graph
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



33
34
35
# File 'lib/rgl/graphxml.rb', line 33

def graph
  @graph
end

Instance Method Details

#tag_start(name, attrs) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/rgl/graphxml.rb', line 39

def tag_start (name, attrs)
  case name
  when 'edge'
    @graph.add_edge(attrs['source'], attrs['target'])
  when 'node'
    @graph.add_vertex(attrs['id'])
  end
end