aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
graphElements.h File Reference

some utils for topology : NodeId, Edge, Arc and consorts ... More...

#include <iostream>
#include <agrum/agrum.h>
#include <agrum/base/core/set.h>
#include <agrum/base/graphs/graphElements_inl.h>
Include dependency graph for graphElements.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  gum::Edge
 The base class for all undirected edges. More...
class  gum::Arc
 The base class for all directed edges. More...

Namespaces

namespace  gum
 gum is the global namespace for all aGrUM entities

Typedefs

using gum::NodeId = Size
 Type for node ids.
template<class VAL>
using gum::NodeProperty = HashTable< NodeId, VAL >
 Property on graph elements.
template<class VAL>
using gum::EdgeProperty = HashTable< Edge, VAL >
 Property on graph elements.
template<class VAL>
using gum::ArcProperty = HashTable< Arc, VAL >
 Property on graph elements.

Functions

std::ostream & gum::operator<< (std::ostream &stream, const Edge &edge)
 to friendly display an edge
std::ostream & gum::operator<< (std::ostream &stream, const Arc &arc)
 to friendly display an arc
using gum::EdgeSet = Set< Edge >
 Some typdefs and define for shortcuts ...
using gum::NodeSet = Set< NodeId >
 Some typdefs and define for shortcuts ...
using gum::ArcSet = Set< Arc >
 Some typdefs and define for shortcuts ...
using gum::ArcSetIterator = ArcSet::const_iterator
 Some typdefs and define for shortcuts ...
using gum::EdgeSetIterator = EdgeSet::const_iterator
 Some typdefs and define for shortcuts ...
using gum::NodeSetIterator = NodeSet::const_iterator
 Some typdefs and define for shortcuts ...
const NodeSet gum::emptyNodeSet
 Some typdefs and define for shortcuts ...

Detailed Description

some utils for topology : NodeId, Edge, Arc and consorts ...

Author
Christophe GONZALES(_at_AMU) and Pierre-Henri WUILLEMIN(_at_LIP6)

This file provides two classes, namely Edge and Arc which represent respectively undirected and directed edges. The "directed/undirected" term may be misleading although in practice this will probably result in how these edges will be drawn. In fact, a more appropriate term would be "symmetric/asymmetric edges": an Arc is an edge in which the extremities have different status whereas in an Edge the role of the extremities is symmetric. For instance, in an arrow, one node is near the head and the other one is farther, hence these nodes have different status and swapping the nodes results in reversing the direction of the arrow. Thus, the nodes in an arrow can be thought of as asymmetric and the arrow's graphical representation contains a pointed extremity so as to account for this asymmetry. Conversely, in a Markov Random Field, an edge between two nodes, x and y, means that x and y are probabilistically dependent of one another. This being a symmetrical relation, there is no difference between edge (x,y) and edge (y,x). Thus, it can be represented by an Edge and, graphically, by an undirected edge.

Usage example:
// creation of an edge between nodes whose IDs are 3 and 4
Edge edge1 (3,4);
// copy the edge into another edge
Edge edge2 (edge1), edge3 = edge4;
// compare two edges
if (Edge(3,4) == Edge(4,3)) cerr << "ok, this is symmetric" << endl;
if (Edge(3,4) != Edge(5,4)) cerr << "different edges" << endl;
// get the extremities of the edge
cerr << edge1.first() << " = 3 and " << edge1.second() << " = 4\n";
cerr << "edge1 = (3," << edge1.other (3) << ")" << endl;
// display the edge in a console
cerr << edge1 << endl;
// creation of an arc (directed edge) from 3 to 4
Arc arc1 (3,4);
*
// compare two arcs
if (Arc(3,4) != Arc(4,3)) cerr << "ok, this is asymmetric" << endl;
// get the extremities of the edge
cerr << arc1.tail() << " = 3 and " << arc1.head() << " = 4\n";
cerr << "arc1 = (3 -> " << edge1.other (3) << ")" << endl;
// display an arc in a console
cerr << arc1 << endl;

Definition in file graphElements.h.