Class: RGL::MutableGraph::MutableGraphParser

### Home Classes Methods

### In Files

- lib/rgl/graphxml.rb

### Parent

Object

### Methods

- ::new
- #tag_start

### Included Modules

- REXML::StreamListener

### Class/Module Index

Quicksearch

- RGL
- RGL::AdjacencyGraph
- RGL::BFSIterator
- RGL::BellmanFordAlgorithm
- RGL::BellmanFordVisitor
- RGL::BidirectionalGraph
- RGL::BipartiteBFSIterator
- RGL::DFSIterator
- RGL::DFSVisitor
- RGL::DOT
- RGL::DOT::Digraph
- RGL::DOT::DirectedEdge
- RGL::DOT::Edge
- RGL::DOT::Element
- RGL::DOT::Graph
- RGL::DOT::Node
- RGL::DOT::Port
- RGL::DOT::Subgraph
- RGL::DijkstraAlgorithm
- RGL::DijkstraVisitor
- RGL::DirectedAdjacencyGraph
- RGL::Edge
- RGL::Edge::DirectedEdge
- RGL::Edge::UnDirectedEdge
- RGL::EdgePropertiesMap
- RGL::EdmondsKarpAlgorithm
- RGL::EdmondsKarpAlgorithm::EdmondsKarpBFSIterator
- RGL::Graph
- RGL::Graph::TarjanSccVisitor
- RGL::GraphIterator
- RGL::GraphVisitor
- RGL::GraphVisitor::ClassMethods
- RGL::GraphVisitor::DistanceMapSupport
- RGL::ImplicitGraph
- RGL::MutableGraph
- RGL::MutableGraph::MutableGraphParser
- RGL::NoEdgeError
- RGL::NoVertexError
- RGL::NonNegativeEdgePropertiesMap
- RGL::NotDirectedError
- RGL::NotUndirectedError
- RGL::PrimAlgorithm
- RGL::TopsortIterator
- Enumerable
- Object

No matching classes.

# 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, line 31
    def initialize(graph)
      @graph = graph
      @graph.remove_vertices(@graph.vertices)
    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, 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.