AudioManager  7.6.6
Native Application Runtime Environment
am::CAmGraph< T, V > Class Template Reference

Class representing a directed or undirected graph. More...

#include <CAmGraph.h>

Public Member Functions

 CAmGraph (const std::vector< T > &v)
 
 CAmGraph ()
 
 ~CAmGraph ()
 
const CAmListNodes & getNodes () const
 
const CAmVertexReferenceList & getVertexList () const
 
const CAmNode< T > * findNode (const T &in)
 Returns pointer to a node which data is equal to the given. More...
 
const CAmVertex< T, V > * findVertex (const CAmNode< T > &edge1, const CAmNode< T > &edge2) const
 Returns pointer to a vertex which two ends are equal to the given nodes. More...
 
bool hasCycles () const
 
CAmNode< T > & addNode (const T &in)
 Adds a new node to the graph with given user data. More...
 
void removeVertex (const CAmNode< T > &edge1, const CAmNode< T > &edge2)
 Removes a vertex with two ends equal to the given nodes . More...
 
void removeAllVerticesToNode (const CAmNode< T > &node)
 Removes all vertices to given node . More...
 
void removeNode (const T &in)
 Removes a node with given user data . More...
 
void removeNode (const CAmNode< T > &node)
 Removes the given node from the graph . More...
 
void connectNodes (const CAmNode< T > &first, const CAmNode< T > &last, const V &vertexData, const int16_t weight=1)
 Connect first with last node and set user data and weight to the vertex. More...
 
bool isAnyVertex (const CAmNode< T > &edge1, const CAmNode< T > &edge2) const
 Exists any vertex with two given ends. More...
 
void reset ()
 Sets the status of all nodes and vertices to GES_NOT_VISITED. More...
 
void clear ()
 Clears all nodes and vertices. More...
 
void trace (std::function< void(const CAmNode< T > &, const std::vector< CAmVertex< T, V > * > &)> cb)
 Goes through all nodes and vertices and calls the callback. More...
 
void getShortestPath (const CAmNode< T > &source, const CAmListNodePtrs &listTargets, std::vector< CAmListNodePtrs > &resultPath)
 Finds the shortest path from given node to all nodes in listTargets. More...
 
void getShortestPath (const CAmNode< T > &source, const CAmNode< T > &destination, CAmListNodePtrs &resultPath)
 Finds the shortest path between two nodes. More...
 
void getShortestPath (const CAmNode< T > &source, const CAmListNodePtrs &listTargets, std::function< void(const am_GraphPathPosition_e, CAmNode< T > &)> cb)
 Finds the shortest path from given node to all nodes in listTargets. More...
 
void getShortestPath (const CAmNode< T > &source, const CAmNode< T > &destination, std::function< void(const am_GraphPathPosition_e, CAmNode< T > &)> cb)
 Finds the shortest path between two given nodes. More...
 
void getAllPaths (CAmNode< T > &src, CAmNode< T > &dst, std::function< bool(const CAmNode< T > *)> cbShouldVisitNode, std::function< void(const CAmNode< T > *)> cbWillVisitNode, std::function< void(const CAmNode< T > *)> cbDidVisitNode, std::function< void(const CAmNodeReferenceList &path)> cbDidFindPath)
 Finds all possible paths between two given nodes. More...
 

Detailed Description

template<class T, class V>
class am::CAmGraph< T, V >

Class representing a directed or undirected graph.

It contains nodes and connections. T, V are types for custom user data.

Definition at line 119 of file CAmGraph.h.

Constructor & Destructor Documentation

template<class T, class V>
am::CAmGraph< T, V >::CAmGraph ( const std::vector< T > &  v)
inlineexplicit

Definition at line 341 of file CAmGraph.h.

template<class T, class V>
am::CAmGraph< T, V >::CAmGraph ( )
inline

Definition at line 353 of file CAmGraph.h.

template<class T, class V>
am::CAmGraph< T, V >::~CAmGraph ( )
inline

Definition at line 354 of file CAmGraph.h.

Member Function Documentation

template<class T, class V>
CAmNode<T>& am::CAmGraph< T, V >::addNode ( const T &  in)
inline

Adds a new node to the graph with given user data.

Returns
reference to the newly inserted node.

Definition at line 410 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::clear ( )
inline

Clears all nodes and vertices.

Definition at line 523 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::connectNodes ( const CAmNode< T > &  first,
const CAmNode< T > &  last,
const V &  vertexData,
const int16_t  weight = 1 
)
inline

Connect first with last node and set user data and weight to the vertex.

Definition at line 481 of file CAmGraph.h.

template<class T, class V>
const CAmNode<T>* am::CAmGraph< T, V >::findNode ( const T &  in)
inline

Returns pointer to a node which data is equal to the given.

Returns
pointer to a node or NULL.

Definition at line 370 of file CAmGraph.h.

template<class T, class V>
const CAmVertex<T,V>* am::CAmGraph< T, V >::findVertex ( const CAmNode< T > &  edge1,
const CAmNode< T > &  edge2 
) const
inline

Returns pointer to a vertex which two ends are equal to the given nodes.

Returns
pointer to a vertex or NULL.

Definition at line 387 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::getAllPaths ( CAmNode< T > &  src,
CAmNode< T > &  dst,
std::function< bool(const CAmNode< T > *)>  cbShouldVisitNode,
std::function< void(const CAmNode< T > *)>  cbWillVisitNode,
std::function< void(const CAmNode< T > *)>  cbDidVisitNode,
std::function< void(const CAmNodeReferenceList &path)>  cbDidFindPath 
)
inline

Finds all possible paths between two given nodes.

Delegates the construction of the path to the caller.

Parameters
srcstart node.
dstdestination node.
cbShouldVisitNodeask the delegate if we should proceed with the current node.
cbWillVisitNodetell the delegate the current node will be visited.
cbDidVisitNodetell the delegate the current node was visited.
cbDidFindPathreturn the path to the delegate.

Definition at line 656 of file CAmGraph.h.

template<class T, class V>
const CAmListNodes& am::CAmGraph< T, V >::getNodes ( ) const
inline

Definition at line 356 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::getShortestPath ( const CAmNode< T > &  source,
const CAmListNodePtrs &  listTargets,
std::vector< CAmListNodePtrs > &  resultPath 
)
inline

Finds the shortest path from given node to all nodes in listTargets.

Parameters
sourcestart node.
listTargetsdestination nodes.
resultPathlist with all shortest paths.

Definition at line 554 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::getShortestPath ( const CAmNode< T > &  source,
const CAmNode< T > &  destination,
CAmListNodePtrs &  resultPath 
)
inline

Finds the shortest path between two nodes.

Parameters
sourcestart node.
destinationdestination node.
resultPathlist with the found shortest paths.

Definition at line 585 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::getShortestPath ( const CAmNode< T > &  source,
const CAmListNodePtrs &  listTargets,
std::function< void(const am_GraphPathPosition_e, CAmNode< T > &)>  cb 
)
inline

Finds the shortest path from given node to all nodes in listTargets.

Delegates the construction of the path to the caller.

Parameters
sourcestart node.
listTargetsdestination nodes.
cbcallabck.

Definition at line 604 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::getShortestPath ( const CAmNode< T > &  source,
const CAmNode< T > &  destination,
std::function< void(const am_GraphPathPosition_e, CAmNode< T > &)>  cb 
)
inline

Finds the shortest path between two given nodes.

Delegates the construction of the path to the caller.

Parameters
sourcestart node.
destinationdestination node.
cbcallabck.

Definition at line 631 of file CAmGraph.h.

template<class T, class V>
const CAmVertexReferenceList& am::CAmGraph< T, V >::getVertexList ( ) const
inline

Definition at line 361 of file CAmGraph.h.

template<class T, class V>
bool am::CAmGraph< T, V >::hasCycles ( ) const
inline

Definition at line 400 of file CAmGraph.h.

template<class T, class V>
bool am::CAmGraph< T, V >::isAnyVertex ( const CAmNode< T > &  edge1,
const CAmNode< T > &  edge2 
) const
inline

Exists any vertex with two given ends.

Returns
TRUE on successfully changed ID.

Definition at line 492 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::removeAllVerticesToNode ( const CAmNode< T > &  node)
inline

Removes all vertices to given node .

Definition at line 436 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::removeNode ( const T &  in)
inline

Removes a node with given user data .

Definition at line 454 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::removeNode ( const CAmNode< T > &  node)
inline

Removes the given node from the graph .

Definition at line 464 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::removeVertex ( const CAmNode< T > &  edge1,
const CAmNode< T > &  edge2 
)
inline

Removes a vertex with two ends equal to the given nodes .

Definition at line 423 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::reset ( )
inline

Sets the status of all nodes and vertices to GES_NOT_VISITED.

Definition at line 500 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::trace ( std::function< void(const CAmNode< T > &, const std::vector< CAmVertex< T, V > * > &)>  cb)
inline

Goes through all nodes and vertices and calls the callback.

Definition at line 535 of file CAmGraph.h.


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