OdinAI
|
#include <SparseGraph.h>
Classes | |
class | ConstEdgeIterator |
class | ConstNodeIterator |
class | EdgeIterator |
class | NodeIterator |
Public Types | |
typedef NODE_TYPE | NodeType |
typedef EDGE_TYPE | EdgeType |
typedef std::vector< NODE_TYPE > | NodeVector |
typedef std::list< EDGE_TYPE > | EdgeList |
typedef std::vector< EdgeList > | EdgeListVector |
Public Member Functions | |
SparseGraph (bool digraph) | |
const NodeType & | GetNode (int index) const |
NodeType & | GetNode (int index) |
const EdgeType & | GetEdge (int from, int to) const |
EdgeType & | GetEdge (int from, int to) |
int | GetNextNodeIndex () const |
int | AddNode (const NodeType &node) |
void | RemoveNode (int node) |
void | AddEdge (const EdgeType &edge) |
void | RemoveEdge (int from, int to) |
int | NumNodes () const |
int | NumActiveNodes () const |
int | NumEdges () const |
bool | IsDigraph () const |
bool | IsEmpty () const |
bool | IsPresent (int node) const |
void | Clear () |
Public Attributes | |
friend | EdgeIterator |
friend | ConstEdgeIterator |
friend | NodeIterator |
friend | ConstNodeIterator |
Sparse graph groups together nodes and edges. Implementation is based on the book: Programming Game AI by Example.
void OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::AddEdge | ( | const EdgeType & | edge | ) |
Add edge to graph.
int OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::AddNode | ( | const NodeType & | node | ) |
Adds a node to the graph, and returns the index.
void OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::Clear | ( | ) |
Clear the whole graph.
const EDGE_TYPE & OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::GetEdge | ( | int | from, |
int | to | ||
) | const |
Returns the edge with the specific from and to parameter. Constant version.
EDGE_TYPE & OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::GetEdge | ( | int | from, |
int | to | ||
) |
Returns the edge with the specific from and to parameter. Non-const version.
const NODE_TYPE & OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::GetNode | ( | int | index | ) | const |
Returns the node by the index. Constant version.
NODE_TYPE & OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::GetNode | ( | int | index | ) |
Returns the node by the index. Non-const version.
|
inline |
Returns true if this graph is directed.
|
inline |
Returns true if this graph does not contain any nodes.
bool OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::IsPresent | ( | int | node | ) | const |
Returns true if the node exist in graph.
int OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::NumActiveNodes | ( | ) | const |
Returns the number of active nodes.
int OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::NumEdges | ( | ) | const |
Returns the number of edges.
int OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::NumNodes | ( | ) | const |
Returns the number of nodes.
void OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::RemoveEdge | ( | int | from, |
int | to | ||
) |
Remove edge from graph.
void OdinAI::SparseGraph< NODE_TYPE, EDGE_TYPE >::RemoveNode | ( | int | node | ) |
Remove node from graph.