SMIL  1.0.4
Graph< NodeT, WeightT > Class Template Reference

Non-oriented graph. More...

Detailed Description

template<class NodeT = size_t, class WeightT = size_t>
class smil::Graph< NodeT, WeightT >

Non-oriented graph.

See also
Edge

#include <DGraph.hpp>

+ Inheritance diagram for Graph< NodeT, WeightT >:
+ Collaboration diagram for Graph< NodeT, WeightT >:

Public Types

typedef Graph< NodeT, WeightT > GraphType
 
typedef NodeT NodeType
 
typedef WeightT NodeWeightType
 
typedef std::map< NodeT, WeightT > NodeValuesType
 
typedef set< NodeT > NodeListType
 
typedef Edge< NodeT, WeightT > EdgeType
 
typedef WeightT EdgeWeightType
 
typedef std::vector< Edge< NodeT, WeightT > > EdgeListType
 
typedef std::vector< size_t > NodeEdgesType
 
typedef std::map< NodeT, NodeEdgesType > NodeEdgeListType
 
- Public Types inherited from BaseObject
typedef void parentClass
 
typedef void(BaseObject::* voidMemberFunc) ()
 

Public Member Functions

 Graph ()
 Default constructor.
 
 Graph (const Graph &rhs)
 Copy constructor.
 
Graphoperator= (const Graph &rhs)
 
void clear ()
 Clear graph content.
 
void addNode (const NodeT &ind)
 Add a node given its index.
 
void addNode (const NodeT &ind, const WeightT &val)
 Add a node given its index and its optional value.
 
int findEdge (const EdgeType &e)
 findEdge() - Find an edge by its content - return its index
 
int findEdge (const NodeT &src, const NodeT &targ)
 findEdge() - Find an edge by its nodes - return its index
 
void addEdge (const EdgeType &e, bool checkIfExists=true)
 Add an edge to the graph. More...
 
void addEdge (const NodeT src, const NodeT targ, WeightT weight=0, bool checkIfExists=true)
 Add an edge to the graph given two nodes src and targ and an optional weight. More...
 
void sortEdges (bool reverse=false)
 Sort edges (by weight as defined by the operator < of class Edge)
 
GraphType clone ()
 clone() -
 
size_t getNodeNbr ()
 getNodeNbr() -
 
size_t getEdgeNbr ()
 getEdgeNbr() -
 
void removeNodeEdges (const NodeT node)
 Remove all edges linked to the node nodeIndex.
 
void removeEdge (const size_t index)
 Remove an edge.
 
void removeEdge (const NodeT src, const NodeT targ)
 Find and remove an edge linking src to targ.
 
void removeEdge (const EdgeType &edge)
 Remove a given edge.
 
void removeHighEdges (EdgeWeightType EdgeThreshold)
 removeHighEdges() - remove edges whose weight are greater then some threshold More...
 
void removeLowEdges (EdgeWeightType EdgeThreshold)
 removeHighEdges() - remove edges whose weight are lesser then some threshold More...
 
NodeListType & getNodes ()
 getNodes() - get the list of nodes More...
 
EdgeListType & getEdges ()
 getEdges() - Get a vector containing the graph edges More...
 
NodeValuesType & getNodeValues ()
 getNodeValues() -
 
NodeEdgeListType & getNodeEdges ()
 getNodeEdges()-
 
NodeEdgesType getNodeEdges (const size_t &node)
 getNodeEdges() - Get a map containing the edges linked to a given node
 
GraphType computeMST ()
 computeMST() - Compute the Minimum Spanning Tree graph
 
virtual void printSelf (ostream &os=std::cout, string s="") const
 printSelf() -
 
map< NodeT, NodeT > labelizeNodes () const
 labelizeNodes() - Labelize the nodes. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject (const char *_className, bool _register=true)
 
 BaseObject (const BaseObject &rhs, bool _register=true)
 
BaseObjectoperator= (const BaseObject &rhs)
 
CoregetCoreInstance ()
 
virtual const char * getInfoString (const char *="") const
 
virtual const char * getClassName () const
 
virtual void setName (const char *_name)
 
virtual const char * getName () const
 
virtual size_t getAllocatedSize () const
 

Protected Member Functions

void removeNode (const NodeT ind)
 
void removeNodeEdge (const NodeT node, const size_t edgeIndex)
 
void propagateLabel (const NodeT ind, const NodeT lbl, map< NodeT, NodeT > &lookup, set< NodeT > &nList) const
 

Protected Attributes

size_t edgeNbr
 
NodeListType nodes
 
NodeValuesType nodeValues
 
EdgeListType edges
 
NodeEdgeListType nodeEdgeList
 
- Protected Attributes inherited from BaseObject
bool registered
 
string className
 
string name
 

Additional Inherited Members

- Public Attributes inherited from BaseObject
bool triggerEvents
 

Member Function Documentation

◆ addEdge() [1/2]

void addEdge ( const EdgeType e,
bool  checkIfExists = true 
)
inline

Add an edge to the graph.

If checkIfExists is true:

  • If the edge doen't exist, create a new one.
  • If the edge already exists, the edge weight will be the minimum between the existing a the new weight.

◆ addEdge() [2/2]

void addEdge ( const NodeT  src,
const NodeT  targ,
WeightT  weight = 0,
bool  checkIfExists = true 
)
inline

Add an edge to the graph given two nodes src and targ and an optional weight.

If checkIfExists is true:

  • If the edge doen't exist, create a new one.
  • If the edge already exists, the edge weight will be the minimum between the existing a the new weight.

◆ removeHighEdges()

void removeHighEdges ( EdgeWeightType  EdgeThreshold)
inline

removeHighEdges() - remove edges whose weight are greater then some threshold

Parameters
[in]EdgeThreshold:

◆ removeLowEdges()

void removeLowEdges ( EdgeWeightType  EdgeThreshold)
inline

removeHighEdges() - remove edges whose weight are lesser then some threshold

Parameters
[in]EdgeThreshold:

◆ getNodes()

NodeListType& getNodes ( )
inline

getNodes() - get the list of nodes

Returns
a handle to the list of nodes in the graph as a set

◆ getEdges()

EdgeListType& getEdges ( )
inline

getEdges() - Get a vector containing the graph edges

Returns
a handle to the list of edges as a vector

◆ labelizeNodes()

map<NodeT, NodeT> labelizeNodes ( ) const
inline

labelizeNodes() - Labelize the nodes.

Give a different label to each group of connected nodes.

Returns
a map [ node, label_value ]

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