StaticDigraph
Declared in lemon/static_graph.h, in the group Graph Structures; the same class on the Doxygen site.
-
class StaticDigraph : public DigraphExtender< StaticDigraphBase >
A static directed graph class.
StaticDigraph is a highly efficient digraph implementation, but it is fully static. It stores only two
intvalues for each node and only fourintvalues for each arc. Moreover it provides faster item iteration than ListDigraph and SmartDigraph, especially usingOutArcItiterators, since its arcs are stored in an appropriate order. However it only provides build() and clear() functions and does not support any other modification of the digraph.Since this digraph structure is completely static, its nodes and arcs can be indexed with integers from the ranges
[0..nodeNum()-1]and[0..arcNum()-1], respectively. The index of an item is the same as its ID, it can be obtained using the corresponding index() or id() function. A node or arc with a certain index can be obtained using node() or arc().This type fully conforms to the Digraph concept. Most of its member functions and nested classes are documented only in the concept class.
This class provides constant time counting for nodes and arcs.
See also
Public Types
-
typedef ExtendedStaticDigraphBase Parent
Public Functions
-
inline StaticDigraph()
Constructor.
Default constructor.
-
inline int nodeNum() const
Number of nodes.
This function returns the number of nodes.
-
inline int arcNum() const
Number of arcs.
This function returns the number of arcs.
-
template< typename Digraph , typename NodeRefMap , typename ArcRefMap >
inline void build( - const Digraph & digraph,
- NodeRefMap & nodeRef,
- ArcRefMap & arcRef
Build the digraph copying another digraph.
This function builds the digraph copying another digraph of any kind. It can be called more than once, but in such case, the whole structure and all maps will be cleared and rebuilt.
This method also makes possible to copy a digraph to a StaticDigraph structure using DigraphCopy.
Note
If you do not need the arc references, then you could use NullMap for the last parameter. However the node references are required by the function itself, thus they must be readable from the map.
- Parameters:
digraph – An existing digraph to be copied.
nodeRef – The node references will be copied into this map. Its key type must be
Digraph::Nodeand its value type must beStaticDigraph::Node. It must conform to the ReadWriteMap concept.arcRef – The arc references will be copied into this map. Its key type must be
Digraph::Arcand its value type must beStaticDigraph::Arc. It must conform to the WriteMap concept.
-
template< typename ArcListIterator >
inline void build( - int n,
- ArcListIterator begin,
- ArcListIterator end
Build the digraph from an arc list.
This function builds the digraph from the given arc list. It can be called more than once, but in such case, the whole structure and all maps will be cleared and rebuilt.
The list of the arcs must be given in the range
[begin, end)specified by STL compatible itartors whosevalue_typemust bestd::pair< int , int >. Each arc must be specified by a pair of integer indices from the range[0..n-1]. The pairs must be in a non-decreasing order with respect to their first values. If the k-th pair in the list is(i,j), thenarc(k-1)will connectnode(i)tonode(j).For example, a simple digraph can be constructed like this.
std::vector< std::pair< int , int > > arcs; arcs.push_back( std::make_pair( 0 , 1 ) ); arcs.push_back( std::make_pair( 0 , 2 ) ); arcs.push_back( std::make_pair( 1 , 3 ) ); arcs.push_back( std::make_pair( 1 , 2 ) ); arcs.push_back( std::make_pair( 3 , 0 ) ); StaticDigraph gr; gr.build( 4 , arcs.begin() , arcs.end() );
- Parameters:
n – The number of nodes.
begin – An iterator pointing to the beginning of the arc list.
end – An iterator pointing to the end of the arc list.
-
inline void clear()
Clear the digraph.
This function erases all nodes and arcs from the digraph.
-
inline Node baseNode( const InArcIt & arc ) const
-
inline Node runningNode( const InArcIt & arc ) const
Public Static Functions
-
static inline Node node( int ix )
The node with the given index.
This function returns the node with the given index.
See also
-
static inline Arc arc( int ix )
The arc with the given index.
This function returns the arc with the given index.
See also
-
static inline int index( Node node )
The index of the given node.
This function returns the index of the the given node.
See also
-
class OutArcIt : public StaticDigraphBase::Arc
Public Functions
-
inline OutArcIt()
-
inline OutArcIt( const StaticDigraph & digraph , const Node & node )
-
inline OutArcIt( const StaticDigraph & digraph , const Arc & arc )
-
inline OutArcIt()
-
typedef ExtendedStaticDigraphBase Parent