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

Basic graph of cliques. More...

#include <cliqueGraph.h>

+ Inheritance diagram for gum::CliqueGraph:
+ Collaboration diagram for gum::CliqueGraph:

Public Attributes

Signaler1< NodeIdonNodeAdded
 
Signaler1< NodeIdonNodeDeleted
 
Signaler2< NodeId, NodeIdonEdgeAdded
 
Signaler2< NodeId, NodeIdonEdgeDeleted
 

Public Member Functions

Constructors / Destructors
 CliqueGraph (Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
 basic constructor: creates an empty clique graph More...
 
 CliqueGraph (const CliqueGraph &from)
 copy constructor More...
 
virtual ~CliqueGraph ()
 destructor More...
 
Accessors/Modifiers
virtual void addEdge (const NodeId first, const NodeId second)
 inserts a new edge between two cliques More...
 
virtual void eraseEdge (const Edge &edge)
 removes an edge (and its separator) from the clique graph More...
 
virtual void clearEdges ()
 removes all edges and their separators More...
 
NodeId addNode (const NodeSet &clique)
 adds a new clique to the graph More...
 
virtual NodeId addNode ()
 adds a new clique to the graph More...
 
virtual void addNode (const NodeId id, const NodeSet &clique)
 try to add a new clique to the graph More...
 
virtual void addNode (const NodeId id)
 try to add a new clique to the graph More...
 
virtual void eraseNode (const NodeId node)
 removes a given clique from the clique graph More...
 
virtual void clear ()
 removes all the cliques and separators from the graph (as well as their adjacent edges) More...
 
const NodeSetclique (const NodeId idClique) const
 returns the set of nodes included into a given clique More...
 
NodeId container (const NodeId idNode) const
 returns the id of a clique containing the node the id of which is in argument More...
 
virtual void setClique (const NodeId idClique, const NodeSet &new_clique)
 changes the set of nodes included into a given clique and returns the new set More...
 
virtual void addToClique (const NodeId clique_id, const NodeId node_id)
 changes the set of nodes included into a given clique and returns the new set More...
 
virtual void eraseFromClique (const NodeId clique_id, const NodeId node_id)
 remove a node from a clique More...
 
const NodeSetseparator (const Edge &edge) const
 returns the separator included in a given edge More...
 
const NodeSetseparator (const NodeId clique1, const NodeId clique) const
 returns the separator included in an edge specified by its extremities More...
 
std::vector< NodeIdcontainerPath (const NodeId node1, const NodeId node2) const
 returns a path from a clique containing node1 to a clique containing node2 More...
 
bool hasRunningIntersection () const
 indicates whether the running intersection property holds More...
 
bool isJoinTree () const
 indicates whether the graph is a join tree More...
 
virtual std::string toString () const
 friendly displays the content of the CliqueGraph More...
 
virtual std::string toDot () const
 friendly displays the content of the CliqueGraph in DOT format More...
 
Operators
CliqueGraphoperator= (const CliqueGraph &from)
 copy operator More...
 
bool operator!= (const CliqueGraph &from) const
 checks whether two clique graphs are different More...
 
bool operator== (const CliqueGraph &from) const
 checks whether two clique graphs are equal More...
 
Operators
bool operator== (const UndiGraph &g) const
 tests whether two UndiGraphs are identical (same nodes, same edges) More...
 
bool operator!= (const UndiGraph &g) const
 tests whether two UndiGraphs are different More...
 
Operators
bool operator== (const NodeGraphPart &p) const
 check whether two NodeGraphParts contain the same nodes More...
 
bool operator!= (const NodeGraphPart &p) const
 check whether two NodeGraphParts contain different nodes More...
 
Operators
bool operator== (const EdgeGraphPart &p) const
 tests whether two EdgeGraphParts contain the same edges More...
 
bool operator!= (const EdgeGraphPart &p) const
 tests whether two EdgeGraphParts contain different edges More...
 
Accessors/Modifiers
bool hasUndirectedCycle () const
 checks whether the graph contains cycles More...
 
virtual UndiGraph partialUndiGraph (NodeSet nodes)
 returns the partial graph formed by the nodes given in parameter More...
 
NodeProperty< NodeIdnodes2ConnectedComponent () const
 returns a property {node:id of connected component} More...
 
Accessors/Modifiers
void populateNodes (const NodeGraphPart &s)
 populateNodes clears *this and fills it with the same nodes as "s" More...
 
template<typename T >
void populateNodesFromProperty (const NodeProperty< T > &h)
 populateNodesFromProperty clears *this and fills it with the keys of "h" More...
 
NodeId nextNodeId () const
 returns a new node id, not yet used by any node More...
 
std::vector< NodeIdaddNodes (Size n)
 insert n nodes More...
 
virtual void addNodeWithId (const NodeId id)
 try to insert a node with the given id More...
 
bool existsNode (const NodeId id) const
 returns true iff the NodeGraphPart contains the given nodeId More...
 
bool exists (const NodeId id) const
 alias for existsNode More...
 
bool emptyNodes () const
 indicates whether there exists nodes in the NodeGraphPart More...
 
bool empty () const
 alias for emptyNodes More...
 
virtual void clearNodes ()
 remove all the nodes from the NodeGraphPart More...
 
Size sizeNodes () const
 returns the number of nodes in the NodeGraphPart More...
 
Size size () const
 alias for sizeNodes More...
 
NodeId bound () const
 returns a number n such that all node ids are strictly lower than n More...
 
NodeSet asNodeSet () const
 returns a copy of the set of nodes represented by the NodeGraphPart More...
 
const NodeGraphPartnodes () const
 return *this as a NodeGraphPart More...
 
node_iterator_safe beginSafe () const
 a begin iterator to parse the set of nodes contained in the NodeGraphPart More...
 
const node_iterator_safeendSafe () const noexcept
 the end iterator to parse the set of nodes contained in the NodeGraphPart More...
 
node_iterator begin () const noexcept
 a begin iterator to parse the set of nodes contained in the NodeGraphPart More...
 
const node_iteratorend () const noexcept
 the end iterator to parse the set of nodes contained in the NodeGraphPart More...
 
template<typename VAL >
NodeProperty< VAL > nodesProperty (VAL(*f)(const NodeId &), Size size=0) const
 a method to create a HashTable with key:NodeId and value:VAL More...
 
template<typename VAL >
NodeProperty< VAL > nodesProperty (const VAL &a, Size size=0) const
 a method to create a hashMap with key:NodeId and value:VAL More...
 
template<typename VAL >
List< VAL > listMapNodes (VAL(*f)(const NodeId &)) const
 a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x)) More...
 
Accessors/Modifiers
bool existsEdge (const Edge &edge) const
 indicates whether a given edge exists More...
 
bool existsEdge (const NodeId n1, const NodeId n2) const
 indicates whether a given edge exists More...
 
bool emptyEdges () const
 indicates wether the EdgeGraphPart contains any edge More...
 
Size sizeEdges () const
 indicates the number of edges stored within the EdgeGraphPart More...
 
const EdgeSetedges () const
 returns the set of edges stored within the EdgeGraphPart More...
 
const NodeSetneighbours (const NodeId id) const
 returns the set of node neighbours to a given node More...
 
void eraseNeighbours (const NodeId id)
 erase all the edges adjacent to a given node More...
 
void unvirtualizedEraseNeighbours (const NodeId id)
 same function as eraseNeighbours but without any virtual call to an erase More...
 
template<typename VAL >
EdgeProperty< VAL > edgesProperty (VAL(*f)(const Edge &), Size size=0) const
 a method to create a hashMap of VAL from a set of edges (using for every edge, say x, the VAL f(x)) More...
 
template<typename VAL >
EdgeProperty< VAL > edgesProperty (const VAL &a, Size size=0) const
 a method to create a hashMap of VAL from a set of edges (using for every edge, say x, the VAL a) More...
 
template<typename VAL >
List< VAL > listMapEdges (VAL(*f)(const Edge &)) const
 a method to create a list of VAL from a set of edges (using for every edge, say x, the VAL f(x)) More...
 
const std::vector< NodeIdundirectedPath (const NodeId node1, const NodeId node2) const
 returns a possible path from node1 to node2 in the edge set More...
 
bool hasUndirectedPath (const NodeId n1, const NodeId n2) const
 return true if n1 and n2 are connected (by an undirected path) in the graph. More...
 
bool hasUndirectedPath (const NodeId n1, const NodeId n2, const NodeSet &except) const
 return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph. More...
 
bool hasUndirectedPath (const NodeSet &n1, const NodeSet &n2, const NodeSet &except) const
 return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph. More...
 

Public Types

typedef NodeGraphPartIterator NodeIterator
 
typedef NodeGraphPartIterator NodeConstIterator
 
typedef NodeGraphPartIteratorSafe NodeIteratorSafe
 
typedef NodeGraphPartIteratorSafe NodeConstIteratorSafe
 
typedef EdgeSetIterator EdgeIterator
 
using node_iterator = NodeGraphPartIterator
 types for STL compliance More...
 
using node_const_iterator = NodeGraphPartIterator
 types for STL compliance More...
 
using node_iterator_safe = NodeGraphPartIteratorSafe
 types for STL compliance More...
 
using node_const_iterator_safe = NodeGraphPartIteratorSafe
 types for STL compliance More...
 

Classes

struct  _RunningIntersect_
 structure used for the computation of the running intersection property More...
 

Detailed Description

Basic graph of cliques.

A CliqueGraph is an undirected graph the nodes of which are Cliques, i.e., sets of NodeIds. Cliques are linked by Edges. These edges contain separators that are actually the intersection of the two Cliques at the extermities of the edge.

Definition at line 57 of file cliqueGraph.h.

Member Typedef Documentation

◆ EdgeIterator

Definition at line 76 of file edgeGraphPart.h.

◆ node_const_iterator

types for STL compliance

Definition at line 258 of file nodeGraphPart.h.

◆ node_const_iterator_safe

types for STL compliance

Definition at line 260 of file nodeGraphPart.h.

◆ node_iterator

types for STL compliance

Definition at line 257 of file nodeGraphPart.h.

◆ node_iterator_safe

types for STL compliance

Definition at line 259 of file nodeGraphPart.h.

◆ NodeConstIterator

Definition at line 267 of file nodeGraphPart.h.

◆ NodeConstIteratorSafe

◆ NodeIterator

Definition at line 266 of file nodeGraphPart.h.

◆ NodeIteratorSafe

Constructor & Destructor Documentation

◆ CliqueGraph() [1/2]

gum::CliqueGraph::CliqueGraph ( Size  nodes_size = HashTableConst::default_size,
bool  nodes_resize_policy = true,
Size  edges_size = HashTableConst::default_size,
bool  edges_resize_policy = true 
)
explicit

basic constructor: creates an empty clique graph

Parameters
nodes_sizethe size of the hash table used to store all the nodes
nodes_resize_policythe resizing policy of this hash table
edges_sizethe size of the hash table used to store all the edges
edges_resize_policythe resizing policy of this hash table

◆ CliqueGraph() [2/2]

gum::CliqueGraph::CliqueGraph ( const CliqueGraph from)

copy constructor

Parameters
fromthe CliqueGraph that will be copied into this

◆ ~CliqueGraph()

virtual gum::CliqueGraph::~CliqueGraph ( )
virtual

destructor

Member Function Documentation

◆ _runningIntersectionDFS_()

bool gum::CliqueGraph::_runningIntersectionDFS_ ( const NodeId  clique,
const NodeId  from,
_RunningIntersect_ infos_DFS 
) const
private

function used for the computation of the running intersection property

◆ _updateSeparators_()

void gum::CliqueGraph::_updateSeparators_ ( const NodeId  clique1)
private

function used to update the separators when a clique is modified

◆ addEdge()

virtual void gum::CliqueGraph::addEdge ( const NodeId  first,
const NodeId  second 
)
virtual

inserts a new edge between two cliques

Parameters
firstthe id of one extremity of the new edge to be inserted
secondthe id of the other extremity of the new edge to be inserted
Warning
if the edge already exists, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeif first and/or second do not belong to the graph nodes

Reimplemented from gum::EdgeGraphPart.

◆ addNode() [1/4]

NodeId gum::CliqueGraph::addNode ( const NodeSet clique)

adds a new clique to the graph

Returns
the id chosen for the new clique

◆ addNode() [2/4]

virtual NodeId gum::CliqueGraph::addNode ( )
virtual

adds a new clique to the graph

Returns
the id chosen for the new clique

Reimplemented from gum::NodeGraphPart.

◆ addNode() [3/4]

virtual void gum::CliqueGraph::addNode ( const NodeId  id,
const NodeSet clique 
)
virtual

try to add a new clique to the graph

Exceptions
DuplicateElementexception is thrown if the id of the clique already exists within the clique graph

◆ addNode() [4/4]

virtual void gum::CliqueGraph::addNode ( const NodeId  id)
virtual

try to add a new clique to the graph

Exceptions
DuplicateElementexception is thrown if the id of the clique already exists within the clique graph

◆ addNodes()

INLINE std::vector< NodeId > gum::NodeGraphPart::addNodes ( Size  n)
inherited

insert n nodes

Parameters
nthe number of nodes to add
Returns
the vector of chosen ids

Definition at line 256 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

256  {
257  std::vector< NodeId > v;
258  v.reserve(N);
259  for (Idx i = 0; i < N; i++)
260  v.push_back(this->addNode());
261  return v;
262  }
+ Here is the call graph for this function:

◆ addNodeWithId()

void gum::NodeGraphPart::addNodeWithId ( const NodeId  id)
virtualinherited

try to insert a node with the given id

Warning
This method should be carefully used. Please prefer populateNodes or populateNodesFromProperty when possible
Exceptions
DuplicateElementexception if the id already exists

Definition at line 131 of file nodeGraphPart.cpp.

References gum::Set< Key, Alloc >::emplace().

131  {
132  if (id >= _boundVal_) {
133  if (id > _boundVal_) { // we have to add holes
135 
136  for (NodeId i = _boundVal_; i < id; ++i)
137  _holes_->insert(i);
138  }
139 
140  _boundVal_ = id + 1;
141 
143  } else {
144  if (_inHoles_(id)) { // we fill a hole
145  _eraseHole_(id);
146  } else {
147  GUM_ERROR(DuplicateElement, "Id " << id << " is already used")
148  }
149  }
150 
151  GUM_EMIT1(onNodeAdded, id);
152  }
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
void _updateEndIteratorSafe_()
updating endIterator (always at max+1)
#define GUM_EMIT1(signal, arg1)
Definition: signaler1.h:41
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Size _holes_size_
value for holes configuration
Signaler1< NodeId > onNodeAdded
bool _inHoles_(NodeId id) const
void _eraseHole_(NodeId id)
to delete hole.
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
bool _holes_resize_policy_
value for holes configuration
+ Here is the call graph for this function:

◆ addToClique()

virtual void gum::CliqueGraph::addToClique ( const NodeId  clique_id,
const NodeId  node_id 
)
virtual

changes the set of nodes included into a given clique and returns the new set

Exceptions
NotFoundexception is thrown if clique_id does not exist
DuplicateElementexception is thrown if clique_id set already contains the node

◆ asNodeSet()

INLINE NodeSet gum::NodeGraphPart::asNodeSet ( ) const
inherited

returns a copy of the set of nodes represented by the NodeGraphPart

Warning
this function is o(n) where n is the number of nodes. In space and in time. Usually, when you need to parse the nodes of a NodeGraphPart, prefer using
for(const auto n : nodes())
rather than
for(const auto n : asNodeSet())
as this is faster and consumes much less memory.

Definition at line 340 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

340  {
341  NodeSet son(sizeNodes());
342 
343  if (!empty()) {
344  for (NodeId n = 0; n < _boundVal_; ++n) {
345  if (!_inHoles_(n)) son.insert(n);
346  }
347  }
348 
349  return son;
350  }
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
bool empty() const
alias for emptyNodes
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
bool _inHoles_(NodeId id) const
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ begin()

INLINE NodeGraphPartIterator gum::NodeGraphPart::begin ( ) const
noexceptinherited

a begin iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 314 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

314  {
315  NodeGraphPartIterator it(*this);
316  it.validate_(); // stop the iterator at the first not-in-holes
317  return it;
318  }
friend class NodeGraphPartIterator
+ Here is the call graph for this function:

◆ beginSafe()

INLINE NodeGraphPartIteratorSafe gum::NodeGraphPart::beginSafe ( ) const
inherited

a begin iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 302 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

302  {
303  NodeGraphPartIteratorSafe it(*this);
304  it.validate_(); // stop the iterator at the first not-in-holes
305  return it;
306  }
friend class NodeGraphPartIteratorSafe
+ Here is the call graph for this function:

◆ bound()

INLINE NodeId gum::NodeGraphPart::bound ( ) const
inherited

returns a number n such that all node ids are strictly lower than n

Definition at line 291 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

291 { return _boundVal_; }
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
+ Here is the call graph for this function:

◆ clear()

virtual void gum::CliqueGraph::clear ( )
virtual

removes all the cliques and separators from the graph (as well as their adjacent edges)

Reimplemented from gum::NodeGraphPart.

◆ clearEdges()

virtual void gum::CliqueGraph::clearEdges ( )
virtual

removes all edges and their separators

Reimplemented from gum::EdgeGraphPart.

◆ clearNodes()

INLINE void gum::NodeGraphPart::clearNodes ( )
virtualinherited

remove all the nodes from the NodeGraphPart

Definition at line 293 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

293 { _clearNodes_(); }
void _clearNodes_()
code for clearing nodes (called twice)
+ Here is the call graph for this function:

◆ clique()

const NodeSet& gum::CliqueGraph::clique ( const NodeId  idClique) const

returns the set of nodes included into a given clique

Exceptions
NotFoundexception is raised if the clique does not belong to the clique graph

◆ container()

NodeId gum::CliqueGraph::container ( const NodeId  idNode) const

returns the id of a clique containing the node the id of which is in argument

Warning
note that this method is time consuming as the clique graph does not contain a priori information about which clique could contain idNode. As a consequence, it searches the cliques until it finds one that actually contains idNode.
Exceptions
NotFoundexception is thrown if no clique contains idNode

◆ containerPath()

std::vector< NodeId > gum::CliqueGraph::containerPath ( const NodeId  node1,
const NodeId  node2 
) const

returns a path from a clique containing node1 to a clique containing node2

Exceptions
NotFoundsuch path cannot be found

◆ edges()

INLINE const EdgeSet & gum::EdgeGraphPart::edges ( ) const
inherited

returns the set of edges stored within the EdgeGraphPart

Definition at line 38 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

38 { return _edges_; }
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
+ Here is the call graph for this function:

◆ edgesProperty() [1/2]

template<typename VAL >
EdgeProperty< VAL > gum::EdgeGraphPart::edgesProperty ( VAL(*)(const Edge &)  f,
Size  size = 0 
) const
inherited

a method to create a hashMap of VAL from a set of edges (using for every edge, say x, the VAL f(x))

Parameters
fa function assigning a VAL to any edge
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of edges. If you do not specify this parameter, the method will assign it for you.

◆ edgesProperty() [2/2]

template<typename VAL >
EdgeProperty< VAL > gum::EdgeGraphPart::edgesProperty ( const VAL &  a,
Size  size = 0 
) const
inherited

a method to create a hashMap of VAL from a set of edges (using for every edge, say x, the VAL a)

Parameters
athe default value assigned to each edge in the returned Property
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of edges. If you do not specify this parameter, the method will assign it for you.

◆ empty()

INLINE bool gum::NodeGraphPart::empty ( ) const
inherited

alias for emptyNodes

Definition at line 289 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

289 { return emptyNodes(); }
bool emptyNodes() const
indicates whether there exists nodes in the NodeGraphPart
+ Here is the call graph for this function:

◆ emptyEdges()

INLINE bool gum::EdgeGraphPart::emptyEdges ( ) const
inherited

indicates wether the EdgeGraphPart contains any edge

Definition at line 34 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

34 { return _edges_.empty(); }
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:700
+ Here is the call graph for this function:

◆ emptyNodes()

INLINE bool gum::NodeGraphPart::emptyNodes ( ) const
inherited

indicates whether there exists nodes in the NodeGraphPart

Definition at line 287 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

287 { return (sizeNodes() == 0); }
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
+ Here is the call graph for this function:

◆ end()

INLINE const NodeGraphPartIterator & gum::NodeGraphPart::end ( ) const
noexceptinherited

the end iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 320 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

320  {
321  return _endIteratorSafe_;
322  }
NodeGraphPartIteratorSafe _endIteratorSafe_
the end iterator (used to speed-up parsings of the NodeGraphPart)
+ Here is the call graph for this function:

◆ endSafe()

INLINE const NodeGraphPartIteratorSafe & gum::NodeGraphPart::endSafe ( ) const
noexceptinherited

the end iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 310 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

310  {
311  return _endIteratorSafe_;
312  }
NodeGraphPartIteratorSafe _endIteratorSafe_
the end iterator (used to speed-up parsings of the NodeGraphPart)
+ Here is the call graph for this function:

◆ eraseEdge()

virtual void gum::CliqueGraph::eraseEdge ( const Edge edge)
virtual

removes an edge (and its separator) from the clique graph

Parameters
edgethe edge to be removed
Warning
if the edge does not exist, nothing is done. In particular, no exception is thrown.

Reimplemented from gum::EdgeGraphPart.

◆ eraseFromClique()

virtual void gum::CliqueGraph::eraseFromClique ( const NodeId  clique_id,
const NodeId  node_id 
)
virtual

remove a node from a clique

If node_id cannot be found in the clique set, then the function does nothing. In particular, it does not throw any exception.

Exceptions
NotFoundexception is thrown if clique_id does not exist

◆ eraseNeighbours()

INLINE void gum::EdgeGraphPart::eraseNeighbours ( const NodeId  id)
inherited

erase all the edges adjacent to a given node

Parameters
idthe node the adjacent edges of which will be removed
Warning
if no edge is adjacent to id, nothing is done. In particular, no exception is thrown.
although this method is not virtual, it calls method eraseEdge( const Edge& edge ) and, as such, has a "virtual" behaviour

Definition at line 79 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

79  {
80  if (_neighbours_.exists(id)) {
81  const NodeSet& set = neighbours(id);
82 
83  for (auto iter = set.beginSafe(); iter != set.endSafe();
84  ++iter) { // safe iterator needed here
85  // warning: use this erase so that you actually use the virtualized
86  // edge removal function
87  eraseEdge(Edge(*iter, id));
88  }
89  }
90  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
NodeProperty< NodeSet *> _neighbours_
for each node, the set of its adjacent edges
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
+ Here is the call graph for this function:

◆ eraseNode()

virtual void gum::CliqueGraph::eraseNode ( const NodeId  node)
virtual

removes a given clique from the clique graph

If the CliqueGraph does not contain the node, then nothing is done. In particular, no exception is raised.

Reimplemented from gum::NodeGraphPart.

◆ exists()

INLINE bool gum::NodeGraphPart::exists ( const NodeId  id) const
inherited

alias for existsNode

Definition at line 277 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

277 { return existsNode(node); }
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
+ Here is the call graph for this function:

◆ existsEdge() [1/2]

INLINE bool gum::EdgeGraphPart::existsEdge ( const Edge edge) const
inherited

indicates whether a given edge exists

Parameters
edgethe edge we test whether or not it belongs to the EdgeGraphPart

Definition at line 40 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

40 { return _edges_.contains(edge); }
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
Definition: set_tpl.h:558
+ Here is the call graph for this function:

◆ existsEdge() [2/2]

INLINE bool gum::EdgeGraphPart::existsEdge ( const NodeId  n1,
const NodeId  n2 
) const
inherited

indicates whether a given edge exists

Parameters
n1the id of one extremity of the edge we test the existence in the EdgeGraphPart
n2the id of the other extremity of the edge we test the existence in the EdgeGraphPart

Definition at line 42 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

42  {
43  return _neighbours_.exists(first) && _neighbours_[first]->exists(second);
44  }
NodeProperty< NodeSet *> _neighbours_
for each node, the set of its adjacent edges
+ Here is the call graph for this function:

◆ existsNode()

INLINE bool gum::NodeGraphPart::existsNode ( const NodeId  id) const
inherited

returns true iff the NodeGraphPart contains the given nodeId

Definition at line 271 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

271  {
272  if (node >= _boundVal_) return false;
273 
274  return (!_inHoles_(node));
275  }
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
bool _inHoles_(NodeId id) const
+ Here is the call graph for this function:

◆ hasRunningIntersection()

bool gum::CliqueGraph::hasRunningIntersection ( ) const

indicates whether the running intersection property holds

The function works properly even if the graph contains cycles.

◆ hasUndirectedCycle()

bool gum::UndiGraph::hasUndirectedCycle ( ) const
inherited

checks whether the graph contains cycles

Definition at line 57 of file undiGraph.cpp.

57  {
58  List< std::pair< NodeId, NodeId > > open_nodes;
59  NodeProperty< bool > examined_nodes = nodesProperty(false);
60  std::pair< NodeId, NodeId > thePair;
61  NodeId current, from_current;
62 
63  for (const auto node: nodes()) {
64  // check if the node has already been examined (if this is not the case,
65  // this means that we are on a new connected component)
66  if (!examined_nodes[node]) {
67  // indicates that we are examining a new node
68  examined_nodes[node] = true;
69 
70  // check recursively all the nodes of node's connected component
71  thePair.first = node;
72  thePair.second = node;
73  open_nodes.insert(thePair);
74 
75  while (!open_nodes.empty()) {
76  // get a node to propagate
77  thePair = open_nodes.front();
78  open_nodes.popFront();
79 
80  current = thePair.first;
81  from_current = thePair.second;
82 
83  // check the neighbours
84  for (const auto new_node: neighbours(current))
85 
86  // avoid to check the node we are coming from
87  if (new_node != from_current) {
88  if (examined_nodes[new_node])
89  return true;
90  else {
91  examined_nodes[new_node] = true;
92  thePair.first = new_node;
93  thePair.second = current;
94  open_nodes.insert(thePair);
95  }
96  }
97  }
98  }
99  }
100 
101  return false;
102  }
NodeProperty< VAL > nodesProperty(VAL(*f)(const NodeId &), Size size=0) const
a method to create a HashTable with key:NodeId and value:VAL
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
Size NodeId
Type for node ids.
Definition: graphElements.h:97

◆ hasUndirectedPath() [1/3]

bool gum::EdgeGraphPart::hasUndirectedPath ( const NodeId  n1,
const NodeId  n2 
) const
inherited

return true if n1 and n2 are connected (by an undirected path) in the graph.

Parameters
n1NodeId
n2NodeId
Returns
bool

Definition at line 166 of file edgeGraphPart.cpp.

References gum::Set< Key, Alloc >::emplace().

166  {
167  NodeSet visited;
168  NodeSet temp;
169 
170  temp.insert(n1);
171  while (!temp.empty()) {
172  NodeId current = *(temp.begin());
173  if (current == n2) return true;
174  temp.erase(current);
175  visited.insert(current);
176  for (auto next: neighbours(current)) {
177  if (!temp.contains(next) && !visited.contains(next)) temp.insert(next);
178  }
179  }
180  return false;
181  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ hasUndirectedPath() [2/3]

bool gum::EdgeGraphPart::hasUndirectedPath ( const NodeId  n1,
const NodeId  n2,
const NodeSet except 
) const
inherited

return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph.

Parameters
n1NodeId
n2NodeId
exceptNodeSet
Warning
n1 in except has no repercussion. However n2 in except naturally leads to 'false'
Returns
bool

Definition at line 183 of file edgeGraphPart.cpp.

References gum::Set< Key, Alloc >::emplace().

183  {
184  NodeSet visited;
185  NodeSet temp;
186 
187  if (except.contains(n2)) return false;
188 
189  temp.insert(n1);
190  while (!temp.empty()) {
191  NodeId current = *(temp.begin());
192  if (current == n2) return true;
193  temp.erase(current);
194  visited.insert(current);
195  for (auto next: neighbours(current)) {
196  if (!temp.contains(next) && !visited.contains(next) && !except.contains(next))
197  temp.insert(next);
198  }
199  }
200  return false;
201  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ hasUndirectedPath() [3/3]

bool gum::EdgeGraphPart::hasUndirectedPath ( const NodeSet n1,
const NodeSet n2,
const NodeSet except 
) const
inherited

return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph.

Parameters
n1NodeSet
n2NodeSet
exceptNodeSet
Returns
bool

Definition at line 203 of file edgeGraphPart.cpp.

References gum::Set< Key, Alloc >::emplace().

205  {
206  NodeSet visited;
207  NodeSet temp;
208 
209  for (auto n: n1)
210  temp.insert(n);
211 
212  while (!temp.empty()) {
213  NodeId current = *(temp.begin());
214  if (n2.contains(current)) return true;
215  temp.erase(current);
216  visited.insert(current);
217  for (auto next: neighbours(current)) {
218  if (!temp.contains(next) && !visited.contains(next) && !except.contains(next))
219  temp.insert(next);
220  }
221  }
222  return false;
223  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ isJoinTree()

bool gum::CliqueGraph::isJoinTree ( ) const

indicates whether the graph is a join tree

◆ listMapEdges()

template<typename VAL >
List< VAL > gum::EdgeGraphPart::listMapEdges ( VAL(*)(const Edge &)  f) const
inherited

a method to create a list of VAL from a set of edges (using for every edge, say x, the VAL f(x))

Parameters
fa function assigning a VAL to any edge

◆ listMapNodes()

template<typename VAL >
List< VAL > gum::NodeGraphPart::listMapNodes ( VAL(*)(const NodeId &)  f) const
inherited

a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x))

Parameters
fa function assigning a VAL to any node

◆ neighbours()

INLINE const NodeSet & gum::EdgeGraphPart::neighbours ( const NodeId  id) const
inherited

returns the set of node neighbours to a given node

Note that the set of nodes returned may be empty if no edge within the EdgeGraphPart is adjacent the given node.

Parameters
idthe node to which the edges are adjacent

Definition at line 74 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

74  {
76  return *(_neighbours_[id]);
77  }
void _checkNeighbours_(const NodeId id) const
when the EdgeGraphPart contains no edge adjacent to a given node, this function adds an empty set ent...
NodeProperty< NodeSet *> _neighbours_
for each node, the set of its adjacent edges
+ Here is the call graph for this function:

◆ nextNodeId()

INLINE NodeId gum::NodeGraphPart::nextNodeId ( ) const
inherited

returns a new node id, not yet used by any node

Warning
a code like
id=nextNodeId();addNode(id);
is basically not thread safe !!
Returns
a node id not yet used by any node within the NodeGraphPart

Definition at line 211 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

211  {
212  NodeId next = 0;
213 
214  // return the first hole if holes exist
215  if (_holes_ && (!_holes_->empty()))
216  next = *(_holes_->begin());
217  else // in other case
218  next = _boundVal_;
219 
220  return next;
221  }
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:700
iterator begin() const
The usual unsafe begin iterator to parse the set.
Definition: set_tpl.h:498
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ nodes()

INLINE const NodeGraphPart & gum::NodeGraphPart::nodes ( ) const
inherited

return *this as a NodeGraphPart

Definition at line 352 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

352  {
353  return *(static_cast< const NodeGraphPart* >(this));
354  }
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
+ Here is the call graph for this function:

◆ nodes2ConnectedComponent()

NodeProperty< NodeId > gum::UndiGraph::nodes2ConnectedComponent ( ) const
inherited

returns a property {node:id of connected component}

Definition at line 152 of file undiGraph.cpp.

152  {
153  NodeProperty< NodeId > res;
154 
155  NodeId numCC = 0;
156  for (const auto node: nodes()) {
157  if (res.exists(node)) continue;
158  NodeSet nodes{node};
159  while (!nodes.empty()) {
160  auto actual = *(nodes.begin());
161  nodes.erase(actual);
162  res.insert(actual, numCC);
163  for (const auto nei: neighbours(actual)) {
164  if (!res.exists(nei))
165  if (!nodes.exists(nei)) nodes.insert(nei);
166  }
167  }
168  numCC += 1;
169  }
170 
171  return res;
172  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
bool exists(const NodeId id) const
alias for existsNode
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
bool empty() const
alias for emptyNodes
node_iterator begin() const noexcept
a begin iterator to parse the set of nodes contained in the NodeGraphPart
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
Size NodeId
Type for node ids.
Definition: graphElements.h:97

◆ nodesProperty() [1/2]

template<typename VAL >
NodeProperty< VAL > gum::NodeGraphPart::nodesProperty ( VAL(*)(const NodeId &)  f,
Size  size = 0 
) const
inherited

a method to create a HashTable with key:NodeId and value:VAL

VAL are computed from the nodes using for all node x, VAL f(x). This method is a wrapper of the same method in HashTable.

See also
HashTable::map.
Parameters
fa function assigning a VAL to any node
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of nodes. If you do not specify this parameter, the method will assign it for you.

◆ nodesProperty() [2/2]

template<typename VAL >
NodeProperty< VAL > gum::NodeGraphPart::nodesProperty ( const VAL &  a,
Size  size = 0 
) const
inherited

a method to create a hashMap with key:NodeId and value:VAL

for all nodes, the value stored is a. This method is a wrapper of the same method in HashTable.

See also
HashTable::map.
Parameters
athe default value assigned to each edge in the returned Property
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of nodes. If you do not specify this parameter, the method will assign it for you.

◆ operator!=() [1/4]

INLINE bool gum::EdgeGraphPart::operator!= ( const EdgeGraphPart p) const
inherited

tests whether two EdgeGraphParts contain different edges

Parameters
pthe EdgeGraphPart that we compare with this

Definition at line 107 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

107  {
108  return _edges_ != p._edges_;
109  }
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
+ Here is the call graph for this function:

◆ operator!=() [2/4]

INLINE bool gum::UndiGraph::operator!= ( const UndiGraph g) const
inherited

tests whether two UndiGraphs are different

Parameters
gthe UndiGraph with which "this" is compared

Definition at line 69 of file undiGraph_inl.h.

References gum::Set< Key, Alloc >::emplace().

69 { return !operator==(p); }
bool operator==(const UndiGraph &g) const
tests whether two UndiGraphs are identical (same nodes, same edges)
Definition: undiGraph_inl.h:65
+ Here is the call graph for this function:

◆ operator!=() [3/4]

bool gum::CliqueGraph::operator!= ( const CliqueGraph from) const

checks whether two clique graphs are different

◆ operator!=() [4/4]

INLINE bool gum::NodeGraphPart::operator!= ( const NodeGraphPart p) const
inherited

check whether two NodeGraphParts contain different nodes

Parameters
pthe NodeGraphPart to be compared with "this"

Definition at line 338 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

338 { return !operator==(p); }
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
+ Here is the call graph for this function:

◆ operator=()

CliqueGraph& gum::CliqueGraph::operator= ( const CliqueGraph from)

copy operator

◆ operator==() [1/4]

INLINE bool gum::EdgeGraphPart::operator== ( const EdgeGraphPart p) const
inherited

tests whether two EdgeGraphParts contain the same edges

Parameters
pthe EdgeGraphPart that we compare with this

Definition at line 103 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

103  {
104  return _edges_ == p._edges_;
105  }
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
+ Here is the call graph for this function:

◆ operator==() [2/4]

INLINE bool gum::UndiGraph::operator== ( const UndiGraph g) const
inherited

tests whether two UndiGraphs are identical (same nodes, same edges)

Parameters
gthe UndiGraph with which "this" is compared

Definition at line 65 of file undiGraph_inl.h.

References gum::Set< Key, Alloc >::emplace().

65  {
67  }
bool operator==(const EdgeGraphPart &p) const
tests whether two EdgeGraphParts contain the same edges
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
+ Here is the call graph for this function:

◆ operator==() [3/4]

bool gum::CliqueGraph::operator== ( const CliqueGraph from) const

checks whether two clique graphs are equal

◆ operator==() [4/4]

INLINE bool gum::NodeGraphPart::operator== ( const NodeGraphPart p) const
inherited

check whether two NodeGraphParts contain the same nodes

Parameters
pthe NodeGraphPart to be compared with "this"

Definition at line 324 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

324  {
325  if (_boundVal_ != p._boundVal_) return false;
326 
327  if (_holes_)
328  if (p._holes_)
329  return (*_holes_ == *p._holes_);
330  else
331  return false;
332  else if (p._holes_)
333  return false;
334 
335  return true;
336  }
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
+ Here is the call graph for this function:

◆ partialUndiGraph()

UndiGraph gum::UndiGraph::partialUndiGraph ( NodeSet  nodes)
virtualinherited

returns the partial graph formed by the nodes given in parameter

Definition at line 139 of file undiGraph.cpp.

139  {
140  UndiGraph partialGraph;
141 
142  for (const auto node: nodes) {
143  partialGraph.addNodeWithId(node);
144 
145  for (const auto nei: neighbours(node))
146  if (nodes.contains(nei) && partialGraph.existsNode(nei)) partialGraph.addEdge(node, nei);
147  }
148 
149  return partialGraph;
150  }
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
UndiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
Definition: undiGraph.cpp:39

◆ populateNodes()

void gum::NodeGraphPart::populateNodes ( const NodeGraphPart s)
inherited

populateNodes clears *this and fills it with the same nodes as "s"

populateNodes should basically be the preferred way to insert nodes with IDs not selected by the internal idFactory.

Parameters
sthe NodeGraphPart to be copied

Definition at line 63 of file nodeGraphPart.cpp.

References gum::Set< Key, Alloc >::emplace().

63  {
64  clear(); // "virtual" flush of the nodes set
65  _holes_size_ = s._holes_size_;
66  _holes_resize_policy_ = s._holes_resize_policy_;
67 
68  if (s._holes_) _holes_ = new NodeSet(*s._holes_);
69 
70  _boundVal_ = s._boundVal_;
71 
73  }
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
void _updateEndIteratorSafe_()
updating endIterator (always at max+1)
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Size _holes_size_
value for holes configuration
virtual void clear()
alias for clearNodes
bool _holes_resize_policy_
value for holes configuration
+ Here is the call graph for this function:

◆ populateNodesFromProperty()

template<typename T >
void gum::NodeGraphPart::populateNodesFromProperty ( const NodeProperty< T > &  h)
inherited

populateNodesFromProperty clears *this and fills it with the keys of "h"

populateNodes should basically be the preferred way to insert nodes with IDs not selected by the internal idFactory.

◆ separator() [1/2]

const NodeSet& gum::CliqueGraph::separator ( const Edge edge) const

returns the separator included in a given edge

Exceptions
NotFoundexception is thrown if the edge does not belong to the clique graph

◆ separator() [2/2]

const NodeSet& gum::CliqueGraph::separator ( const NodeId  clique1,
const NodeId  clique 
) const

returns the separator included in an edge specified by its extremities

Exceptions
NotFoundexception is thrown if the edge does not belong to the clique graph

◆ setClique()

virtual void gum::CliqueGraph::setClique ( const NodeId  idClique,
const NodeSet new_clique 
)
virtual

changes the set of nodes included into a given clique and returns the new set

Exceptions
NotFoundexception is thrown if idClique is not a clique of the clique graph

◆ size()

INLINE Size gum::NodeGraphPart::size ( ) const
inherited

alias for sizeNodes

Definition at line 269 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

269 { return sizeNodes(); }
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
+ Here is the call graph for this function:

◆ sizeEdges()

INLINE Size gum::EdgeGraphPart::sizeEdges ( ) const
inherited

indicates the number of edges stored within the EdgeGraphPart

Definition at line 36 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

36 { return _edges_.size(); }
EdgeSet _edges_
the set of all the edges contained within the EdgeGraphPart
Size size() const noexcept
Returns the number of elements in the set.
Definition: set_tpl.h:694
+ Here is the call graph for this function:

◆ sizeNodes()

INLINE Size gum::NodeGraphPart::sizeNodes ( ) const
inherited

returns the number of nodes in the NodeGraphPart

Definition at line 265 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

265  {
266  return (_holes_) ? (_boundVal_ - _holes_->size()) : _boundVal_;
267  }
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
Size size() const noexcept
Returns the number of elements in the set.
Definition: set_tpl.h:694
+ Here is the call graph for this function:

◆ toDot()

virtual std::string gum::CliqueGraph::toDot ( ) const
virtual

friendly displays the content of the CliqueGraph in DOT format

Reimplemented from gum::UndiGraph.

◆ toString()

virtual std::string gum::CliqueGraph::toString ( ) const
virtual

friendly displays the content of the CliqueGraph

Reimplemented from gum::NodeGraphPart.

◆ undirectedPath()

const std::vector< NodeId > gum::EdgeGraphPart::undirectedPath ( const NodeId  node1,
const NodeId  node2 
) const
inherited

returns a possible path from node1 to node2 in the edge set

Parameters
node1the id from which the path begins
node2the id to which the path ends
Exceptions
NotFoundexception is raised if no path can be found between the two nodes

Definition at line 125 of file edgeGraphPart.cpp.

References gum::Set< Key, Alloc >::emplace().

126  {
127  // not recursive version => use a FIFO for simulating the recursion
128  List< NodeId > nodeFIFO;
129  nodeFIFO.pushBack(n2);
130 
131  // mark[node] = predecessor if visited, else mark[node] does not exist
132  NodeProperty< NodeId > mark;
133  mark.insert(n2, n2);
134 
135  NodeId current;
136 
137  while (!nodeFIFO.empty()) {
138  current = nodeFIFO.front();
139  nodeFIFO.popFront();
140 
141  // check the neighbour
142  for (const auto new_one: neighbours(current)) {
143  if (mark.exists(new_one)) // if this node is already marked, stop
144  continue;
145 
146  mark.insert(new_one, current);
147 
148  if (new_one == n1) {
149  std::vector< NodeId > v;
150 
151  for (current = n1; current != n2; current = mark[current])
152  v.push_back(current);
153 
154  v.push_back(n2);
155 
156  return v;
157  }
158 
159  nodeFIFO.pushBack(new_one);
160  }
161  }
162 
163  GUM_ERROR(NotFound, "no path found")
164  }
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ unvirtualizedEraseNeighbours()

INLINE void gum::EdgeGraphPart::unvirtualizedEraseNeighbours ( const NodeId  id)
inherited

same function as eraseNeighbours but without any virtual call to an erase

Parameters
idthe node whose ingoing arcs will be removed

Definition at line 92 of file edgeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

92  {
93  if (_neighbours_.exists(id)) {
94  const NodeSet& set = neighbours(id);
95 
96  for (auto iter = set.beginSafe(); iter != set.endSafe();
97  ++iter) { // safe iterator needed here
98  EdgeGraphPart::eraseEdge(Edge(*iter, id));
99  }
100  }
101  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
const NodeSet & neighbours(const NodeId id) const
returns the set of node neighbours to a given node
NodeProperty< NodeSet *> _neighbours_
for each node, the set of its adjacent edges
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
+ Here is the call graph for this function:

Member Data Documentation

◆ _cliques_

NodeProperty< NodeSet > gum::CliqueGraph::_cliques_
private

the set of nodes contained into the cliques

Definition at line 240 of file cliqueGraph.h.

◆ _separators_

EdgeProperty< NodeSet > gum::CliqueGraph::_separators_
private

the set of nodes contained into the separators

Definition at line 243 of file cliqueGraph.h.

◆ onEdgeAdded

Signaler2< NodeId, NodeId > gum::EdgeGraphPart::onEdgeAdded
inherited

Definition at line 78 of file edgeGraphPart.h.

◆ onEdgeDeleted

Signaler2< NodeId, NodeId > gum::EdgeGraphPart::onEdgeDeleted
inherited

Definition at line 79 of file edgeGraphPart.h.

◆ onNodeAdded

Signaler1< NodeId > gum::NodeGraphPart::onNodeAdded
inherited

Definition at line 271 of file nodeGraphPart.h.

◆ onNodeDeleted

Signaler1< NodeId > gum::NodeGraphPart::onNodeDeleted
inherited

Definition at line 272 of file nodeGraphPart.h.


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