SMIL 1.1.2
Loading...
Searching...
No Matches
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 Member Functions

 Graph ()
 Default constructor.
 
 Graph (const Graph &rhs)
 Copy constructor.
 
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.
 
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.
 
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
 
void removeLowEdges (EdgeWeightType EdgeThreshold)
 removeHighEdges() - remove edges whose weight are lesser then some threshold
 
NodeListType & getNodes ()
 getNodes() - get the list of nodes
 
EdgeListType & getEdges ()
 getEdges() - Get a vector containing the graph edges
 
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.
 

Member Function Documentation

◆ addEdge() [1/2]

template<class NodeT = size_t, class WeightT = size_t>
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]

template<class NodeT = size_t, class WeightT = size_t>
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()

template<class NodeT = size_t, class WeightT = size_t>
void removeHighEdges ( EdgeWeightType  EdgeThreshold)
inline

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

Parameters
[in]EdgeThreshold:

◆ removeLowEdges()

template<class NodeT = size_t, class WeightT = size_t>
void removeLowEdges ( EdgeWeightType  EdgeThreshold)
inline

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

Parameters
[in]EdgeThreshold:

◆ getNodes()

template<class NodeT = size_t, class WeightT = size_t>
NodeListType & getNodes ( )
inline

getNodes() - get the list of nodes

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

◆ getEdges()

template<class NodeT = size_t, class WeightT = size_t>
EdgeListType & getEdges ( )
inline

getEdges() - Get a vector containing the graph edges

Returns
a handle to the list of edges as a vector

◆ labelizeNodes()

template<class NodeT = size_t, class WeightT = size_t>
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: