#include <graph.h>
Inheritance diagram for gtc::_base_graph< K, W, T >:
Public Methods | |
void | add_node (const K &k) |
Adds a node to the graph. More... | |
void | add_node (const K &k, const T &t) |
Adds a node to the graph, with an associated data value. More... | |
std::size_t | order () |
Returns the number of nodes in the graph. | |
size_t | size () |
Returns the number of edges in the graph. | |
T & | operator[] (const K &k) |
Returns reference to data of node with a given key value. More... | |
virtual iterator | begin () |
Returns an iterator to the first node in the graph. More... | |
virtual iterator | end () |
Returns an iterator past the last node in the graph. | |
virtual iterator | find (const K &k) |
Returns an iterator to the node with the given key value. | |
virtual bool | is_edge (const K &k1, const K &k2)=0 |
Determines if an edge exists given key values of two nodes. | |
edge_iterator | begin (const K &k) |
Returns an edge_iterator to the first edge extending from node k. | |
edge_iterator | end (const K &k) |
Returns an edge_iterator past the last edge extending from node k. | |
template<typename F> F | BFS (const K &k, F f) |
Performs a breadth-first search (traversal) on the graph. | |
template<typename F> F | DFS (const K &k, F f) |
Performs a depth-first search (traversal) on the graph. More... | |
Protected Methods | |
_base_graph () | |
Creates a graph with no nodes. More... | |
_base_graph (size_t n) | |
Createa a graph with n nodes, first key is 1. | |
_base_graph (size_t n, const K &k) | |
Creates a graph with n nodes, first key is k. More... | |
template<typename F> | _base_graph (size_t n, F f) |
Creates a graph with n nodes, function f generates keys. More... | |
Protected Attributes | |
std::map< K, T > | nod |
std::list< edge > | edg |
This is an abstract base class upon which all the other main classes of this library are built. It contans the basic node and node navigation functionality. Since it is an abstract base class, it may not be instantiated.
All function documented for this class, however, are availble in the other graph classes contained in this library.
|
Creates a graph with no nodes. Creates a graph with no nodes. Use the add_node function to add nodes to the graph. |
|
Creates a graph with n nodes, first key is k. < Creates a graph with n nodes. Key of the first node is initialized to 1. Keys of subsequent nodes are generated using the post-increment operator. Note: This constructor may not be used for key types that cannot be initialized with an integer, or do not support the post-increment operator. |
|
Creates a graph with n nodes, function f generates keys. < Creates a graph with n nodes. Key of the first node is initialized to k. Keys of subsequent nodes are generated using the post-increment operator. Note: This constructor may not be used for key types that do not support the post-increment operator. |
|
Adds a node to the graph, with an associated data value. < Adds a node to the graph. Key value of node value is set to k. The associated data value is initialized using the default constructor for T. |
|
Adds a node to the graph. < Creates a graph with n nodes. Function, or function object, f must be a function implemented to take no parameters and return an object of type K. On the first call, f is expected to return the key value of the first node. Subsequent calls to f are expected to return the next appropriate key values for subsequently created nodes. |
|
Returns an iterator to the first node in the graph. < Adds a node to the graph. Key value of node is set to k, and t is used to initialize the node's data value. |
|
Performs a depth-first search (traversal) on the graph. < Performs a breadth-first search (traversal) on the graph beginning with node with key value k. For each node visited during the traversal function, or function object, f is called. The expected prototype of f is:
void f (const K& k); |
|
Returns reference to data of node with a given key value. You may use this operator to gain direct access to a node's data value. The return value is a reference, so it may be used to facilitate changes to the data. |