#include <qgarlib/GenUGraph.H>
A node is described by class qgar::GenNode. It contains:
An edge is described by class qgar::GenEdge. It contains:
A graph is represented as:
Partially inspired by the LEDA library (when it was a free software). See http://www.mpi-sb.mpg.de/LEDA/.
The class is not supposed to be derived: No function member (destructor or whatever else) is virtual.
Neither copy constructor nor assignment operator are defined.
For efficiency reasons, the validity of pointers given as arguments to function members is not checked. In particular:
The deletion of a graph causes the deletion of all its nodes and edges. Consequently, a program abortion may occur when:
GenUGraph<int,int> g; GenNode<int,int> n(1); GenEdge<int,int> e(1); g.addNode(&n); // prohibited! g.addEdge(&e); // prohibited!
Definition at line 143 of file GenUGraph.H.
Public Types | |
Types | |
| typedef TNODE | node_type |
| Type of the data stored in a node. | |
| typedef node_type & | node_type_reference |
| Reference to qgar::GenUGraph::node_type. | |
| typedef const node_type & | node_type_const_reference |
| Constant reference to qgar::GenUGraph::node_type. | |
| typedef node_type * | node_type_pointer |
| Pointer to qgar::GenUGraph::node_type. | |
| typedef const node_type * | node_type_const_pointer |
| Constant pointer to qgar::GenUGraph::node_type. | |
| typedef TEDGE | edge_type |
| Type of the data stored in an edge. | |
| typedef edge_type & | edge_type_reference |
| Reference to qgar::GenUGraph::edge_type. | |
| typedef const edge_type & | edge_type_const_reference |
| Constant reference to qgar::GenUGraph::edge_type. | |
| typedef edge_type * | edge_type_pointer |
| Pointer to qgar::GenUGraph::edge_type. | |
| typedef const edge_type * | edge_type_const_pointer |
| Constant pointer to qgar::GenUGraph::edge_type. | |
| typedef std::list< GenNode< node_type, edge_type > * > | nodes_list_type |
| Type of the nodes list. | |
| typedef std::list< GenEdge< node_type, edge_type > * > | edges_list_type |
| Type of the edges list. | |
Public Member Functions | |
Constructors | |
| GenUGraph () | |
| Default constructor. | |
| GenUGraph (GenNode< node_type, edge_type > *const aPNode) | |
| Initialize from (a pointer to) a node. | |
| GenUGraph (GenEdge< node_type, edge_type > *const aPEdge) | |
| Initialize from (a pointer to) an edge. | |
Destructor | |
Copy constructor. | |
| virtual | ~GenUGraph () |
| Virtual destructor. | |
Graph characteristics | |
| bool | empty () const |
| Return true if the graph is empty. | |
| int | sizeNodes () const |
| Return the number of nodes. | |
| int | sizeEdges () const |
| Return the number of edges. | |
Node access | |
| GenNode< node_type, edge_type > * | pEntryNode () const |
| Return a pointer to the entry node, or 0 if the nodes list is empty. | |
| nodes_list_type & | getNodes () |
| Get the nodes list. | |
| const nodes_list_type & | accessNodes () const |
| Get (a constant reference to) the nodes list. | |
| nodes_list_type | nodes () const |
| Get a copy of the nodes list. | |
Edge access | |
| GenEdge< node_type, edge_type > * | pEntryEdge () const |
| Get a pointer to the entry edge, or 0 if the edges list is empty. | |
| edges_list_type & | getEdges () |
| Get the edges list. | |
| const edges_list_type & | accessEdges () const |
| Get (a constant reference to) the edges list. | |
| edges_list_type | edges () const |
| Get a copy of the edges list. | |
Insertion of created nodes | |
| GenNode< node_type, edge_type > * | addNode (node_type_const_reference aData, short int aFlag=0) |
| Just insert a new node created from given data and flag. | |
| GenNode< node_type, edge_type > * | addNode (GenEdge< node_type, edge_type > *const aPEdge, node_type_const_reference aData, short int aFlag=0) |
| Insert a new node and link it to given edge of the graph. | |
| GenNode< node_type, edge_type > * | addNode (GenEdge< node_type, edge_type > *const aPEdge1, GenEdge< node_type, edge_type > *const aPEdge2, node_type_const_reference aData, short int aFlag=0) |
| Insert a new node between given edges of the graph. | |
| GenNode< node_type, edge_type > * | addNodeAtSource (GenEdge< node_type, edge_type > *const aPEdge, node_type_const_reference aData, short int aFlag=0) |
| Insert a new node as source of given edge of the graph. | |
| GenNode< node_type, edge_type > * | addNodeAtTarget (GenEdge< node_type, edge_type > *const aPEdge, node_type_const_reference aData, short int aFlag=0) |
| Insert a new node as target of given edge of the graph. | |
Insertion of existing nodes | |
| GenNode< node_type, edge_type > * | addNode (GenNode< node_type, edge_type > *const aPNode) |
| Just insert (a pointer to) a node in the graph. | |
| GenNode< node_type, edge_type > * | addNode (GenNode< node_type, edge_type > *const aPNode, GenEdge< node_type, edge_type > *const aPEdge) |
| Insert given (pointer to) node in the graph, as source or target of given (pointed) edge. | |
| GenNode< node_type, edge_type > * | addNode (GenNode< node_type, edge_type > *const aPNode, GenEdge< node_type, edge_type > *const aPEdge1, GenEdge< node_type, edge_type > *const aPEdge2) |
| Insert a node between two given edges of the graph. | |
| GenNode< node_type, edge_type > * | addNodeAtSource (GenNode< node_type, edge_type > *const aPNode, GenEdge< node_type, edge_type > *const aPEdge) |
| Insert given node as source of given edge of the graph. | |
| GenNode< node_type, edge_type > * | addNodeAtTarget (GenNode< node_type, edge_type > *const aPNode, GenEdge< node_type, edge_type > *const aPEdge) |
| Insert given node as target of given edge of the graph. | |
Insertion of created edges | |
| GenEdge< node_type, edge_type > * | addEdge (edge_type_const_reference aData, short int aFlag=0) |
| Just insert a new edge created from given data and flag. | |
| GenEdge< node_type, edge_type > * | addEdge (GenNode< node_type, edge_type > *const aPNode, edge_type_const_reference aData, short int aFlag=0) |
| Insert a new edge in the graph, so that given (pointed) node becomes its source. | |
| GenEdge< node_type, edge_type > * | addEdge (GenNode< node_type, edge_type > *const aPSource, GenNode< node_type, edge_type > *const aPTarget, edge_type_const_reference aData, short int aFlag=0) |
| Insert an new edge between two given nodes of the graph. | |
Insertion of existing edges | |
| GenEdge< node_type, edge_type > * | addEdge (GenEdge< node_type, edge_type > *const aPEdge) |
| Insert (a pointer to) an edge in the graph. | |
| GenEdge< node_type, edge_type > * | addEdge (GenEdge< node_type, edge_type > *const aPEdge, GenNode< node_type, edge_type > *const aPNode) |
| Insert given (pointer to) edge in the graph, so as given (pointed) node becomes its source or its target. | |
| GenEdge< node_type, edge_type > * | addEdge (GenEdge< node_type, edge_type > *const aPEdge, GenNode< node_type, edge_type > *const aPNode1, GenNode< node_type, edge_type > *const aPNode2) |
| Insert an edge between two given nodes of the graph. | |
| GenEdge< node_type, edge_type > * | addEdgeBySource (GenEdge< node_type, edge_type > *const aPEdge, GenNode< node_type, edge_type > *const aPNode) |
| Insert given (pointer to) edge in the graph, so as given (pointed) node becomes its source. | |
| GenEdge< node_type, edge_type > * | addEdgeByTarget (GenEdge< node_type, edge_type > *const aPEdge, GenNode< node_type, edge_type > *const aPNode) |
| Insert given (pointer to) edge in the graph, so as given (pointed) node becomes its target. | |
Node removal | |
Warning: The user is in charge of the deletion of the removed nodes. | |
| GenNode< node_type, edge_type > * | remove (GenNode< node_type, edge_type > *const aPNode) |
| Remove given (pointer to) node from the graph, and return it. | |
| GenNode< node_type, edge_type > * | remove (typename nodes_list_type::iterator aPos) |
| Remove (pointer to) node at given position in the nodes list of the graph, and return it. | |
Edge removal | |
Warning: The user is in charge of the deletion of the removed edges. | |
| GenEdge< node_type, edge_type > * | remove (GenEdge< node_type, edge_type > *const aPEdge) |
| Remove given (pointer to) edge from the graph, and return it. | |
| GenEdge< node_type, edge_type > * | remove (typename edges_list_type::iterator aPos) |
| Remove (pointer to) edge at given position in the edges list of the graph, and return it. | |
Protected Attributes | |
Nodes and edges lists | |
Assignment. | |
| nodes_list_type | _nodes |
| List of the nodes of the graph. | |
| edges_list_type | _edges |
| List of the edges of the graph. | |
|
|||||
|
Type of the data stored in an edge.
Definition at line 182 of file GenUGraph.H. |
|
|||||
|
Constant pointer to qgar::GenUGraph::edge_type.
Definition at line 202 of file GenUGraph.H. |
|
|||||
|
Constant reference to qgar::GenUGraph::edge_type.
Definition at line 192 of file GenUGraph.H. |
|
|||||
|
Pointer to qgar::GenUGraph::edge_type.
Definition at line 197 of file GenUGraph.H. |
|
|||||
|
Reference to qgar::GenUGraph::edge_type.
Definition at line 187 of file GenUGraph.H. |
|
|||||
|
Type of the edges list.
Definition at line 212 of file GenUGraph.H. |
|
|||||
|
Type of the data stored in a node.
Definition at line 157 of file GenUGraph.H. |
|
|||||
|
Constant pointer to qgar::GenUGraph::node_type.
Definition at line 177 of file GenUGraph.H. |
|
|||||
|
Constant reference to qgar::GenUGraph::node_type.
Definition at line 167 of file GenUGraph.H. |
|
|||||
|
Pointer to qgar::GenUGraph::node_type.
Definition at line 172 of file GenUGraph.H. |
|
|||||
|
Reference to qgar::GenUGraph::node_type.
Definition at line 162 of file GenUGraph.H. |
|
|||||
|
Type of the nodes list.
Definition at line 207 of file GenUGraph.H. |
|
|||||||||
|
Default constructor. Edges and nodes lists are empty. Definition at line 60 of file GenUGraph.TCC. |
|
||||||||||
|
Initialize from (a pointer to) a node.
|
|
||||||||||
|
Initialize from (a pointer to) an edge.
Definition at line 78 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
|||||||||
|
Virtual destructor.
Definition at line 90 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges, and qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
|||||||||
|
Get (a constant reference to) the edges list.
Definition at line 234 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
|||||||||
|
Get (a constant reference to) the nodes list.
Definition at line 182 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
||||||||||||||||||||
|
Insert an edge between two given nodes of the graph. The given nodes are supposed to belong to the current graph:
|
|
||||||||||||||||
|
Insert given (pointer to) edge in the graph, so as given (pointed) node becomes its source or its target. The given node is supposed to belong to the graph:
|
|
||||||||||
|
Insert (a pointer to) an edge in the graph. The (pointer to the) edge is just inserted in the edges list of the graph, and is not connected to any node.
Definition at line 459 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
||||||||||||||||||||||||
|
Insert an new edge between two given nodes of the graph. An edge is created, with (pointers to) nodes aPSource and aPTarget as source and target, respectively. The new edge is inserted in the edges list of both nodes, and in the edges list of the graph.
|
|
||||||||||||||||||||
|
Insert a new edge in the graph, so that given (pointed) node becomes its source. The (pointer to the) new edge is inserted in the edges list of the node, and in the edges list of the graph. The given node becomes the source of the new edge.
|
|
||||||||||||||||
|
Just insert a new edge created from given data and flag. The (pointer to the) edge is just inserted in the edges list of the graph, and is not connected to any node.
|
|
||||||||||||||||
|
Insert given (pointer to) edge in the graph, so as given (pointed) node becomes its source. The given node is supposed to belong to the graph:
|
|
||||||||||||||||
|
Insert given (pointer to) edge in the graph, so as given (pointed) node becomes its target. The given node is supposed to belong to the graph:
|
|
||||||||||||||||||||
|
Insert a node between two given edges of the graph. The given edges are supposed to belong to the current graph:
|
|
||||||||||||||||
|
Insert given (pointer to) node in the graph, as source or target of given (pointed) edge. The given edge is supposed to belong to the current graph:
|
|
||||||||||
|
Just insert (a pointer to) a node in the graph. The (pointer to the) node is just inserted in the nodes list of the graph, and is not connected to any edge.
|
|
||||||||||||||||||||||||
|
Insert a new node between given edges of the graph. The (pointer to the) node is inserted in the nodes list of the graph. The (pointers to the) edges are inserted in the edges list of the node. The new node becomes the source of the first (resp. second) edge if the source is free, otherwise it becomes the target of the first (resp. second) edge.
|
|
||||||||||||||||||||
|
Insert a new node and link it to given edge of the graph. The (pointer to the) node is inserted in the nodes list of the graph. The (pointer to the) edge is inserted in the edges list of the node. The new node becomes the source of the given edge if the source is free, otherwise it becomes the target of the edge.
|
|
||||||||||||||||
|
Just insert a new node created from given data and flag. The (pointer to the) node is just inserted in the nodes list of the graph, and is not connected to any edge.
|
|
||||||||||||||||
|
Insert given node as source of given edge of the graph. The given edge is supposed to belong to the current graph:
|
|
||||||||||||||||||||
|
Insert a new node as source of given edge of the graph.
|
|
||||||||||||||||
|
Insert given node as target of given edge of the graph. The given edge is supposed to belong to the current graph:
|
|
||||||||||||||||||||
|
Insert a new node as target of given edge of the graph.
|
|
|||||||||
|
Get a copy of the edges list.
Definition at line 243 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
|||||||||
|
Return true if the graph is empty.
Definition at line 119 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges, and qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
|||||||||
|
Get the edges list.
Definition at line 224 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
|||||||||
|
Get the nodes list.
Definition at line 172 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
|||||||||
|
Get a copy of the nodes list.
Definition at line 191 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
|||||||||
|
Get a pointer to the entry edge, or 0 if the edges list is empty.
Definition at line 207 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
|||||||||
|
Return a pointer to the entry node, or 0 if the nodes list is empty.
Definition at line 155 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
||||||||||
|
Remove (pointer to) edge at given position in the edges list of the graph, and return it. If the given position is the end of the edges list of the graph, the graph remains unchanged and the function returns 0. Otherwise, the given edge is removed from the edges list of its source and target nodes, and is removed from the edges list of the graph.
|
|
||||||||||
|
Remove given (pointer to) edge from the graph, and return it. If the given (pointer to) edge is not in the edges list of the graph, the graph remains unchanged and the function returns 0. Otherwise, the given edge is removed from the edges list of its source and target nodes, and is removed from the edges list of the graph.
Definition at line 614 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges, and qgar::GenUGraph< TNODE, TEDGE >::remove(). |
|
||||||||||
|
Remove (pointer to) node at given position in the nodes list of the graph, and return it. If the given position is the end of the nodes list of the graph, the graph remains unchanged and the function returns 0. Otherwise, each edge adjacent to the given node is removed from the graph, and the given node is removed from the nodes list of the graph.
|
|
||||||||||
|
Remove given (pointer to) node from the graph, and return it. If the given (pointer to) node is not in the nodes list of the graph, the graph remains unchanged and the function returns 0. Otherwise, each edge adjacent to the given node is removed from the graph, and the given node is removed from the nodes list of the graph.
Referenced by qgar::GenUGraph< TNODE, TEDGE >::remove(). |
|
|||||||||
|
Return the number of edges.
Definition at line 139 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_edges. |
|
|||||||||
|
Return the number of nodes.
Definition at line 129 of file GenUGraph.TCC. References qgar::GenUGraph< TNODE, TEDGE >::_nodes. |
|
|||||
|
|||||
|
List of the nodes of the graph.
Definition at line 880 of file GenUGraph.H. Referenced by qgar::GenUGraph< TNODE, TEDGE >::accessNodes(), qgar::GenUGraph< TNODE, TEDGE >::empty(), qgar::GenUGraph< TNODE, TEDGE >::getNodes(), qgar::GenUGraph< TNODE, TEDGE >::nodes(), qgar::GenUGraph< TNODE, TEDGE >::pEntryNode(), qgar::GenUGraph< TNODE, TEDGE >::sizeNodes(), and qgar::GenUGraph< TNODE, TEDGE >::~GenUGraph(). |