golib  0.5
goGraphAlgorithm< NodeType, EdgeType > Class Template Reference

Running through a Graph. More...

#include <gograph.h>

Public Member Functions

bool breadthFirst (NodeType *root)
 BFS. More...
 
bool breadthFirstTree (NodeType *root)
 
bool depthFirstRecursive (NodeType *root)
 
bool depthFirst (NodeType *root)
 
bool depthFirstTree (NodeType *root)
 Same as depthFirst(), plus fills parent fields in the nodes. More...
 
virtual bool action (NodeType *node)
 
virtual bool action (const NodeType *node) const
 

Detailed Description

template<class NodeType, class EdgeType>
class goGraphAlgorithm< NodeType, EdgeType >

Running through a Graph.

NodeType should be derived from goGraphNode or provide the same functionality. EdgeType should be derived from goGraphEdge or provide the same functionality.

Note
Algorithms currently work for graphs with a single connected component
Todo:
Add support for multiple connected components (simply by supplying a set of all nodes).

Member Function Documentation

◆ breadthFirst()

template<class NodeType, class EdgeType>
bool goGraphAlgorithm< NodeType, EdgeType >::breadthFirst ( NodeType *  root)
inline

BFS.

Note
All nodes need to be reset to NodeType::NORMAL state before calling this.
Parameters
rootNode to start at.
Returns
True if successful, false otherwise.

◆ depthFirstTree()

template<class NodeType, class EdgeType>
bool goGraphAlgorithm< NodeType, EdgeType >::depthFirstTree ( NodeType *  root)
inline

Same as depthFirst(), plus fills parent fields in the nodes.

In order for all nodes to be visited, their status field must be set to NORMAL prior to calling any of the BFS or DFS methods.

Parameters
rootRoot node (to start with).
nodeListNode list of the complete graph.
Todo:
Find a better name for this.
Returns
True if successful, false otherwise.

The documentation for this class was generated from the following file: