Module: RGL::BidirectionalGraph

### Home Classes Methods

### In Files

- lib/rgl/bidirectional.rb

### Methods

- #degree
- #each_in_neighbor
- #in_degree

### Included Modules

- RGL::Graph

### 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::BidirectionalGraph

BGL defines the concept BidirectionalGraph as follows:

The BidirectionalGraph concept refines IncidenceGraph and adds the requirement for efficient access to the in-edges of each vertex. This concept is separated from IncidenceGraph because, for directed graphs, efficient access to in-edges typically requires more storage space, and many algorithms do not require access to in-edges. For undirected graphs, this is not an issue; because the in_edges() and out_edges() functions are the same, they both return the edges incident to the vertex.

### Public Instance Methods

degree(v) click to toggle source

Returns the number of in-edges plus out-edges (for directed graphs) or the number of incident edges (for undirected graphs) of vertex v.

    # File lib/rgl/bidirectional.rb, line 41
    def degree(v)
      in_degree(v) + out_degree(v)
    end

each_in_neighbor(v) click to toggle source

Iterator providing access to the in-edges (for directed graphs) or incident edges (for undirected graphs) of vertex v. For both directed and undirected graphs, the target of an out-edge is required to be vertex v and the source is required to be a vertex that is adjacent to v.

    # File lib/rgl/bidirectional.rb, line 24
    def each_in_neighbor(v)
      raise NotImplementedError
      yield u
    end

in_degree(v) click to toggle source

Returns the number of in-edges (for directed graphs) or the number of incident edges (for undirected graphs) of vertex v.

    # File lib/rgl/bidirectional.rb, line 32
    def in_degree(v)
      r = 0
      each_in_neighbor(v) { |u| r += 1 }
      r
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.