void SetIndex(int NewIndex);
Because often you will require that a node contains additional information,
GraphNode is typically used as a base class from which to derive custom-
built nodes. For example, a navigation graph’s nodes must store spatial
information, and a dependency graph’s nodes must contain information
about the assets they represent.
A node class designed for use within a navigation graph might look
something like this:
template < class extra_info = void*>
class NavGraphNode : public GraphNode
//the node's position
//often you will require a navgraph node to contain additional information.
//For example a node might represent a pickup such as armor in which
//case m_ExtraInfo could be an enumerated value denoting the pickup type,
//thereby enabling a search algorithm to search a graph for specific items.
//Going one step further, m_ExtraInfo could be a pointer to the instance of
//the item type the node is twinned with. This would allow a search algorithm
//to test the status of the pickup during the search. See Chapter 8 for further
/*INTERFACE OMITTED */
Please note that although the node class listed here uses a 2D vector to rep
resent a node’s position, a graph can exist in any number of dimensions
you like. If you are creating a navigation graph for a 3D game, simply use
3D vectors. Everything will work just the same.
The GraphEdge Class
The GraphEdge class encapsulates the basic information required to denote a
connection between two graph nodes. Here’s the code:
The Secret Life of Graphs
Implementing a Graph Class