SmartGraph is a simple and fast graph implementation. It is also quite memory efficient but at the price that it does not support node and edge deletion (except for the Snapshot feature).
This type fully conforms to the Graph 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, edges and arcs.
- See Also
- concepts::Graph
-
SmartDigraph
#include <lemon/smart_graph.h>
Inherits GraphExtender< Base >.
|
class | Snapshot |
| Class to make a snapshot of the graph and to restore it later. More...
|
|
|
| SmartGraph () |
|
Node | addNode () |
| Add a new node to the graph.
|
|
Edge | addEdge (Node u, Node v) |
| Add a new edge to the graph.
|
|
bool | valid (Node n) const |
| Node validity check.
|
|
bool | valid (Edge e) const |
| Edge validity check.
|
|
bool | valid (Arc a) const |
| Arc validity check.
|
|
void | clear () |
| Clear the graph.
|
|
void | reserveNode (int n) |
| Reserve memory for nodes.
|
|
void | reserveEdge (int m) |
| Reserve memory for edges.
|
|
This function adds a new node to the graph.
- Returns
- The new node.
Edge addEdge |
( |
Node |
u, |
|
|
Node |
v |
|
) |
| |
|
inline |
This function adds a new edge to the graph between nodes u
and v
with inherent orientation from node u
to node v
.
- Returns
- The new edge.
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 graph.
- Warning
- A removed node (using Snapshot) could become valid again if new nodes are added to the graph.
bool valid |
( |
Edge |
e | ) |
const |
|
inline |
This function gives back true
if the given edge is valid, i.e. it is a real edge of the graph.
- Warning
- A removed edge (using Snapshot) could become valid again if new edges are added to the graph.
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 graph.
- Warning
- A removed arc (using Snapshot) could become valid again if new edges are added to the graph.
This function erases all nodes and arcs from the graph.
void reserveNode |
( |
int |
n | ) |
|
|
inline |
Using this function, it is possible to avoid superfluous memory allocation: if you know that the graph you want to build will be large (e.g. it will contain millions of nodes and/or edges), then it is worth reserving space for this amount before starting to build the graph.
- See Also
- reserveEdge()
void reserveEdge |
( |
int |
m | ) |
|
|
inline |
Using this function, it is possible to avoid superfluous memory allocation: if you know that the graph you want to build will be large (e.g. it will contain millions of nodes and/or edges), then it is worth reserving space for this amount before starting to build the graph.
- See Also
- reserveNode()