aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::Edge Class Reference

The base class for all undirected edges. More...

#include <graphElements.h>

Public Member Functions

Constructors / Destructors
 Edge (NodeId aN1, NodeId aN2)
 constructs a new edge (aN1,aN2) More...
 
 Edge (const Edge &src)
 copy constructor More...
 
 ~Edge ()
 destructor More...
 
Accessors
NodeId other (NodeId id) const
 returns an extremal node of an edge given the ID of the other one More...
 
NodeId first () const
 returns one extremal node ID (whichever one it is is unspecified) More...
 
NodeId second () const
 returns the node ID of the other extremal node ID More...
 
Operators
Edgeoperator= (const Edge &src)
 copy operator More...
 
bool operator== (const Edge &src) const
 checks whether two undirected edges are equal More...
 
bool operator!= (const Edge &src) const
 checks whether two undirected edges are different More...
 

Detailed Description

The base class for all undirected edges.

This class is used as a basis for manipulating any undirected edge in any graph. By undirected edge, we mean a symmetric edge, i.e., an edge in which the order of the nodes is unimportant. For instance, in Markov Random fields, 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 undirected edge and, in aGrUM, by an 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;

Definition at line 144 of file graphElements.h.

Constructor & Destructor Documentation

◆ Edge() [1/2]

gum::Edge::Edge ( NodeId  aN1,
NodeId  aN2 
)

constructs a new edge (aN1,aN2)

Parameters
aN1the ID of the first extremal node
aN2the ID of the second extremal node

◆ Edge() [2/2]

gum::Edge::Edge ( const Edge src)

copy constructor

◆ ~Edge()

gum::Edge::~Edge ( )

destructor

Member Function Documentation

◆ first()

NodeId gum::Edge::first ( ) const

returns one extremal node ID (whichever one it is is unspecified)

◆ operator!=()

bool gum::Edge::operator!= ( const Edge src) const

checks whether two undirected edges are different

Two Edge are different if at least one extremal node of an edge is not an extremal node of the other edge. For instance, (4,5) != (5,6).

◆ operator=()

Edge& gum::Edge::operator= ( const Edge src)

copy operator

◆ operator==()

bool gum::Edge::operator== ( const Edge src) const

checks whether two undirected edges are equal

Two Edge are equal if they have the same extremal nodes, whetever their order. For instance (3,4) == (4,3).

◆ other()

NodeId gum::Edge::other ( NodeId  id) const

returns an extremal node of an edge given the ID of the other one

◆ second()

NodeId gum::Edge::second ( ) const

returns the node ID of the other extremal node ID

Member Data Documentation

◆ n1

NodeId gum::Edge::n1
private

the extremal nodes of the edge (their order is unimportant)

Definition at line 202 of file graphElements.h.

◆ n2

NodeId gum::Edge::n2
private

Definition at line 202 of file graphElements.h.


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