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

Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org. More...

#include <iostream>
#include <agrum/agrum.h>
#include <agrum/tools/core/set.h>
#include <agrum/tools/graphs/graphElements_inl.h>
+ Include dependency graph for graphElements.h:

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 edgesThis class is used as a basis for manipulating all directed edges (i.e., edges in which the order of the nodes is meaningful). More...
 

Namespaces

 gum
 Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.
 

Typedefs

typedef Size gum::NodeId
 Type for node ids. More...
 
typedef Set< NodeId > gum::NodeSet
 Some typdefs and define for shortcuts ... More...
 
typedef Set< Edge > gum::EdgeSet
 Some typdefs and define for shortcuts ... More...
 
typedef Set< Arc > gum::ArcSet
 Some typdefs and define for shortcuts ... More...
 
typedef ArcSet::const_iterator gum::ArcSetIterator
 Some typdefs and define for shortcuts ... More...
 
typedef EdgeSet::const_iterator gum::EdgeSetIterator
 Some typdefs and define for shortcuts ... More...
 
typedef NodeSet::const_iterator gum::NodeSetIterator
 Some typdefs and define for shortcuts ... More...
 
template<class VAL >
using gum::NodeProperty = HashTable< NodeId, VAL >
 Property on graph elements. More...
 
template<class VAL >
using gum::EdgeProperty = HashTable< Edge, VAL >
 Property on graph elements. More...
 
template<class VAL >
using gum::ArcProperty = HashTable< Arc, VAL >
 Property on graph elements. More...
 

Functions

std::ostream & gum::operator<< (std::ostream &stream, const Edge &edge)
 to friendly display an edge More...
 
std::ostream & gum::operator<< (std::ostream &stream, const Arc &arc)
 to friendly display an arc More...
 

Detailed Description

Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN() & Christophe GONZALES() info_at_agrum_dot_org.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/. some utils for topology : NodeId, Edge, Arc and consorts ...

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

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.