Classes | Public Member Functions | Private Member Functions

SmartDigraph Class Reference


Detailed Description

SmartDigraph is a simple and fast digraph implementation. It is also quite memory efficient but at the price that it does not support node and arc deletion (except for the Snapshot feature).

This type fully conforms to the Digraph concept and it also provides some additional functionalities. 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:
concepts::Digraph
SmartGraph

#include <lemon/smart_graph.h>

Inherits lemon::DigraphExtender< SmartDigraphBase >.

List of all members.

Classes

class  Snapshot
 Class to make a snapshot of the digraph and to restore it later. More...

Public Member Functions

 SmartDigraph ()
Node addNode ()
 Add a new node to the digraph.
Arc addArc (Node s, Node t)
 Add a new arc to the digraph.
bool valid (Node n) const
 Node validity check.
bool valid (Arc a) const
 Arc validity check.
Node split (Node n, bool connect=true)
 Split a node.
void clear ()
 Clear the digraph.
void reserveNode (int n)
 Reserve memory for nodes.
void reserveArc (int m)
 Reserve memory for arcs.

Private Member Functions

 SmartDigraph (const SmartDigraph &)
 Digraphs are not copy constructible. Use DigraphCopy instead.
void operator= (const SmartDigraph &)
 Assignment of a digraph to another one is not allowed. Use DigraphCopy instead.

Constructor & Destructor Documentation

SmartDigraph ( ) [inline]

Constructor.


Member Function Documentation

Node addNode ( ) [inline]

This function adds a new node to the digraph.

Returns:
The new node.
Arc addArc ( Node  s,
Node  t 
) [inline]

This function adds a new arc to the digraph with source node s and target node t.

Returns:
The new arc.
bool valid ( Node  n) const [inline]

This function gives back true if the given node is valid, i.e. it is a real node of the digraph.

Warning:
A removed node (using Snapshot) could become valid again if new nodes are added to the digraph.
bool valid ( Arc  a) const [inline]

This function gives back true if the given arc is valid, i.e. it is a real arc of the digraph.

Warning:
A removed arc (using Snapshot) could become valid again if new arcs are added to the graph.
Node split ( Node  n,
bool  connect = true 
) [inline]

This function splits the given node. First, a new node is added to the digraph, then the source of each outgoing arc of node n is moved to this new node. If the second parameter connect is true (this is the default value), then a new arc from node n to the newly created node is also added.

Returns:
The newly created node.
Note:
All iterators remain valid.
Warning:
This functionality cannot be used together with the Snapshot feature.
void clear ( ) [inline]

This function erases all nodes and arcs from the digraph.

void reserveNode ( int  n) [inline]

Using this function, it is possible to avoid superfluous memory allocation: if you know that the digraph you want to build will be large (e.g. it will contain millions of nodes and/or arcs), then it is worth reserving space for this amount before starting to build the digraph.

See also:
reserveArc()
void reserveArc ( int  m) [inline]

Using this function, it is possible to avoid superfluous memory allocation: if you know that the digraph you want to build will be large (e.g. it will contain millions of nodes and/or arcs), then it is worth reserving space for this amount before starting to build the digraph.

See also:
reserveNode()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines