aGrUM 2.3.2
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)
 Edge (const Edge &src)
 copy constructor
 ~Edge ()
 destructor
Accessors
GUM_NODISCARD NodeId other (NodeId id) const
 returns an extremal node of an edge given the ID of the other one
GUM_NODISCARD NodeId first () const
 returns one extremal node ID (whichever one it is is unspecified)
GUM_NODISCARD NodeId second () const
 returns the node ID of the other extremal node ID
Operators
Edgeoperator= (const Edge &src)
 copy operator
bool operator== (const Edge &src) const =default
 checks whether two undirected edges are equal

Private Attributes

NodeId n1
 the extremal nodes of the edge (their order is unimportant)
NodeId n2

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;
Edge(NodeId aN1, NodeId aN2)
constructs a new edge (aN1,aN2)

Definition at line 164 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

Referenced by Edge(), operator=(), and operator==().

Here is the caller graph for this function:

◆ Edge() [2/2]

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

copy constructor

References Edge().

Here is the call graph for this function:

◆ ~Edge()

gum::Edge::~Edge ( )

destructor

Member Function Documentation

◆ first()

GUM_NODISCARD NodeId gum::Edge::first ( ) const

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

References GUM_NODISCARD.

Referenced by gum::SpanningForestPrim::_computeInAComponent_(), and gum::EdgeGraphPart::eraseEdge().

Here is the caller graph for this function:

◆ operator=()

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

copy operator

References Edge().

Here is the call graph for this function:

◆ operator==()

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

checks whether two undirected edges are equal

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

References Edge().

Here is the call graph for this function:

◆ other()

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

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

References GUM_NODISCARD.

◆ second()

GUM_NODISCARD NodeId gum::Edge::second ( ) const

returns the node ID of the other extremal node ID

References GUM_NODISCARD.

Referenced by gum::SpanningForestPrim::_computeInAComponent_(), and gum::EdgeGraphPart::eraseEdge().

Here is the caller graph for this function:

Member Data Documentation

◆ n1

NodeId gum::Edge::n1
private

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

Definition at line 217 of file graphElements.h.

◆ n2

NodeId gum::Edge::n2
private

Definition at line 218 of file graphElements.h.


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