class RGL::MutableGraph::MutableGraphParser
Used to parse a subset of GraphML into an RGL
graph implementation.
Public Class Methods
new(graph)
click to toggle source
First resets graph
to be empty and stores a reference for use with tag_start
.
# File lib/rgl/graphxml.rb 31 def initialize(graph) 32 @graph = graph 33 @graph.remove_vertices(@graph.vertices) 34 end
Public Instance Methods
tag_start(name, attrs)
click to toggle source
Processes incoming edge and node elements from GraphML in order to populate the graph given to new.
# File lib/rgl/graphxml.rb 39 def tag_start(name, attrs) 40 case name 41 when 'edge' 42 @graph.add_edge(attrs['source'], attrs['target']) 43 when 'node' 44 @graph.add_vertex(attrs['id']) 45 end 46 end