AudioManager  7.5.11
Native Application Runtime Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 (const CAmNode< T > &src, const CAmNode< T > &dst, std::function< void(const CAmNodeReferenceList &path)> cb)
 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 118 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 306 of file CAmGraph.h.

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

Definition at line 318 of file CAmGraph.h.

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

Definition at line 319 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 375 of file CAmGraph.h.

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

Clears all nodes and vertices.

Definition at line 488 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 446 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 335 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 352 of file CAmGraph.h.

template<class T, class V>
void am::CAmGraph< T, V >::getAllPaths ( const CAmNode< T > &  src,
const CAmNode< T > &  dst,
std::function< void(const CAmNodeReferenceList &path)>  cb 
)
inline

Finds all possible paths between two given nodes.

Delegates the construction of the path to the caller.

Parameters
srcstart node.
dstdestination node.
cbcallabck.

Definition at line 618 of file CAmGraph.h.

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

Definition at line 321 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 519 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 550 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 569 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 596 of file CAmGraph.h.

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

Definition at line 326 of file CAmGraph.h.

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

Definition at line 365 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 457 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 401 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 419 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 429 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 388 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 465 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 500 of file CAmGraph.h.


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