OdinAI

- Main Page
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables
Public Member Functions | List of all members
OdinAI::DijkstraGraphSearch< GraphType, TargetCondition > Class Template Reference

Given a graph, and an optional target, it calculates the shortest path from the source node to the target. More...

`#include <DijkstraGraphSearch.h>`

## Public Member Functions
| DijkstraGraphSearch (const GraphType &graph, int source, int target=-1)
std::vector< const Edge * > | GetSPT () const
std::list< int > | GetPath () const
int | GetCostToTarget () const
int | GetCostToNode (unsigned int nd) const

## Detailed Description

### template<class GraphType, class TargetCondition = int>
class OdinAI::DijkstraGraphSearch< GraphType, TargetCondition >

Given a graph, and an optional target, it calculates the shortest path from the source node to the target.

The target maybe anything, it maybe a node, or it maybe a condition. Set target condition to your own class with a static function bool IsTarget, where the first argument should be a const graph reference, and the second an int, for the current node id. Below is an example:

class TargetCondition
{
public:
TargetCondition(int target) : m_target(target) {}
int m_target;
template<class GraphType>
static bool IsTarget(const GraphType &graph, int nodeID)
{
return m_target == nodeID;
}
};

## Member Function Documentation

template<class GraphType , class TargetCondition = int>

int OdinAI::DijkstraGraphSearch< GraphType, TargetCondition >::GetCostToNode | ( | unsigned int | nd | ) | const
| inline

Get cost to any node. NOTE it will only work if the node is on the SPT tree.

Returns
  Cost from source node to this node.

template<class GraphType , class TargetCondition = int>

int OdinAI::DijkstraGraphSearch< GraphType, TargetCondition >::GetCostToTarget | ( |  | ) | const
| inline

Get cost to our target.

Returns
  Cost to our target.

template<class GraphType , class TargetCondition >

std::list< int > OdinAI::DijkstraGraphSearch< GraphType, TargetCondition >::GetPath | ( |  | ) | const

Get the path. The list is empty if no path found.

Returns
  The path represented as a list with the nodes that you must traverse between.

template<class GraphType , class TargetCondition = int>

std::vector<const Edge*> OdinAI::DijkstraGraphSearch< GraphType, TargetCondition >::GetSPT | ( |  | ) | const
| inline

Get our shortest path tree, in other words the shortest path from any node to any node.

Returns
  The shortest path tree.

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

- E:/Development/Projects/OdinAI/Include/OdinAI/DijkstraGraphSearch.h