![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Basic graph of cliques. More...
#include <cliqueGraph.h>
Public Attributes | |
Signaler1< NodeId > | onNodeAdded |
Signaler1< NodeId > | onNodeDeleted |
Signaler2< NodeId, NodeId > | onEdgeAdded |
Signaler2< NodeId, NodeId > | onEdgeDeleted |
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 NodeSet & | clique (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 NodeSet & | separator (const Edge &edge) const |
returns the separator included in a given edge More... | |
const NodeSet & | separator (const NodeId clique1, const NodeId clique) const |
returns the separator included in an edge specified by its extremities More... | |
std::vector< NodeId > | containerPath (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 | |
CliqueGraph & | operator= (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< NodeId > | nodes2ConnectedComponent () 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< NodeId > | addNodes (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 NodeGraphPart & | nodes () 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_safe & | endSafe () 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_iterator & | end () 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 EdgeSet & | edges () const |
returns the set of edges stored within the EdgeGraphPart More... | |
const NodeSet & | neighbours (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< NodeId > | undirectedPath (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... | |
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.
|
inherited |
Definition at line 76 of file edgeGraphPart.h.
|
inherited |
types for STL compliance
Definition at line 258 of file nodeGraphPart.h.
|
inherited |
types for STL compliance
Definition at line 260 of file nodeGraphPart.h.
|
inherited |
types for STL compliance
Definition at line 257 of file nodeGraphPart.h.
|
inherited |
types for STL compliance
Definition at line 259 of file nodeGraphPart.h.
|
inherited |
Definition at line 267 of file nodeGraphPart.h.
|
inherited |
Definition at line 269 of file nodeGraphPart.h.
|
inherited |
Definition at line 266 of file nodeGraphPart.h.
|
inherited |
Definition at line 268 of file nodeGraphPart.h.
|
explicit |
basic constructor: creates an empty clique graph
nodes_size | the size of the hash table used to store all the nodes |
nodes_resize_policy | the resizing policy of this hash table |
edges_size | the size of the hash table used to store all the edges |
edges_resize_policy | the resizing policy of this hash table |
gum::CliqueGraph::CliqueGraph | ( | const CliqueGraph & | from | ) |
copy constructor
from | the CliqueGraph that will be copied into this |
|
virtual |
destructor
|
private |
function used for the computation of the running intersection property
|
private |
function used to update the separators when a clique is modified
inserts a new edge between two cliques
first | the id of one extremity of the new edge to be inserted |
second | the id of the other extremity of the new edge to be inserted |
InvalidNode | if first and/or second do not belong to the graph nodes |
Reimplemented from gum::EdgeGraphPart.
adds a new clique to the graph
|
virtual |
adds a new clique to the graph
Reimplemented from gum::NodeGraphPart.
try to add a new clique to the graph
DuplicateElement | exception is thrown if the id of the clique already exists within the clique graph |
|
virtual |
try to add a new clique to the graph
DuplicateElement | exception is thrown if the id of the clique already exists within the clique graph |
insert n nodes
n | the number of nodes to add |
Definition at line 256 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
try to insert a node with the given id
DuplicateElement | exception if the id already exists |
Definition at line 131 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
changes the set of nodes included into a given clique and returns the new set
NotFound | exception is thrown if clique_id does not exist |
DuplicateElement | exception is thrown if clique_id set already contains the node |
|
inherited |
returns a copy of the set of nodes represented by the NodeGraphPart
Definition at line 340 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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().
|
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().
|
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().
|
virtual |
removes all the cliques and separators from the graph (as well as their adjacent edges)
Reimplemented from gum::NodeGraphPart.
|
virtual |
removes all edges and their separators
Reimplemented from gum::EdgeGraphPart.
|
virtualinherited |
remove all the nodes from the NodeGraphPart
Definition at line 293 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns the set of nodes included into a given clique
NotFound | exception is raised if the clique does not belong to the clique graph |
returns the id of a clique containing the node the id of which is in argument
NotFound | exception is thrown if no clique contains idNode |
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
NotFound | such path cannot be found |
|
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().
|
inherited |
a method to create a hashMap of VAL from a set of edges (using for every edge, say x, the VAL f(x))
f | a function assigning a VAL to any edge |
size | an 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. |
|
inherited |
a method to create a hashMap of VAL from a set of edges (using for every edge, say x, the VAL a)
a | the default value assigned to each edge in the returned Property |
size | an 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. |
|
inherited |
alias for emptyNodes
Definition at line 289 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
indicates wether the EdgeGraphPart contains any edge
Definition at line 34 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
indicates whether there exists nodes in the NodeGraphPart
Definition at line 287 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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().
|
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().
|
virtual |
removes an edge (and its separator) from the clique graph
edge | the edge to be removed |
Reimplemented from gum::EdgeGraphPart.
|
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.
NotFound | exception is thrown if clique_id does not exist |
|
inherited |
erase all the edges adjacent to a given node
id | the node the adjacent edges of which will be removed |
Definition at line 79 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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.
alias for existsNode
Definition at line 277 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
indicates whether a given edge exists
edge | the 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().
indicates whether a given edge exists
n1 | the id of one extremity of the edge we test the existence in the EdgeGraphPart |
n2 | the 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().
returns true iff the NodeGraphPart contains the given nodeId
Definition at line 271 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
bool gum::CliqueGraph::hasRunningIntersection | ( | ) | const |
indicates whether the running intersection property holds
The function works properly even if the graph contains cycles.
|
inherited |
checks whether the graph contains cycles
Definition at line 57 of file undiGraph.cpp.
return true if n1 and n2 are connected (by an undirected path) in the graph.
n1 | NodeId |
n2 | NodeId |
Definition at line 166 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph.
n1 | NodeId |
n2 | NodeId |
except | NodeSet |
Definition at line 183 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph.
n1 | NodeSet |
n2 | NodeSet |
except | NodeSet |
Definition at line 203 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
bool gum::CliqueGraph::isJoinTree | ( | ) | const |
indicates whether the graph is a join tree
|
inherited |
a method to create a list of VAL from a set of edges (using for every edge, say x, the VAL f(x))
f | a function assigning a VAL to any edge |
|
inherited |
a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x))
f | a function assigning a VAL to any node |
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.
id | the node to which the edges are adjacent |
Definition at line 74 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
returns a new node id, not yet used by any node
Definition at line 211 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
return *this as a NodeGraphPart
Definition at line 352 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
returns a property {node:id of connected component}
Definition at line 152 of file undiGraph.cpp.
|
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.
f | a function assigning a VAL to any node |
size | an 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. |
|
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.
a | the default value assigned to each edge in the returned Property |
size | an 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. |
|
inherited |
tests whether two EdgeGraphParts contain different edges
p | the EdgeGraphPart that we compare with this |
Definition at line 107 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
tests whether two UndiGraphs are different
g | the UndiGraph with which "this" is compared |
Definition at line 69 of file undiGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
bool gum::CliqueGraph::operator!= | ( | const CliqueGraph & | from | ) | const |
checks whether two clique graphs are different
|
inherited |
check whether two NodeGraphParts contain different nodes
p | the NodeGraphPart to be compared with "this" |
Definition at line 338 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
CliqueGraph& gum::CliqueGraph::operator= | ( | const CliqueGraph & | from | ) |
copy operator
|
inherited |
tests whether two EdgeGraphParts contain the same edges
p | the EdgeGraphPart that we compare with this |
Definition at line 103 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
tests whether two UndiGraphs are identical (same nodes, same edges)
g | the UndiGraph with which "this" is compared |
Definition at line 65 of file undiGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
bool gum::CliqueGraph::operator== | ( | const CliqueGraph & | from | ) | const |
checks whether two clique graphs are equal
|
inherited |
check whether two NodeGraphParts contain the same nodes
p | the NodeGraphPart to be compared with "this" |
Definition at line 324 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns the partial graph formed by the nodes given in parameter
Definition at line 139 of file undiGraph.cpp.
|
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.
s | the NodeGraphPart to be copied |
Definition at line 63 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
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.
returns the separator included in a given edge
NotFound | exception is thrown if the edge does not belong to the clique graph |
returns the separator included in an edge specified by its extremities
NotFound | exception is thrown if the edge does not belong to the clique graph |
|
virtual |
changes the set of nodes included into a given clique and returns the new set
NotFound | exception is thrown if idClique is not a clique of the clique graph |
|
inherited |
alias for sizeNodes
Definition at line 269 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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().
|
inherited |
returns the number of nodes in the NodeGraphPart
Definition at line 265 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
friendly displays the content of the CliqueGraph in DOT format
Reimplemented from gum::UndiGraph.
|
virtual |
friendly displays the content of the CliqueGraph
Reimplemented from gum::NodeGraphPart.
|
inherited |
returns a possible path from node1 to node2 in the edge set
node1 | the id from which the path begins |
node2 | the id to which the path ends |
NotFound | exception 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().
|
inherited |
same function as eraseNeighbours but without any virtual call to an erase
id | the node whose ingoing arcs will be removed |
Definition at line 92 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
the set of nodes contained into the cliques
Definition at line 240 of file cliqueGraph.h.
|
private |
the set of nodes contained into the separators
Definition at line 243 of file cliqueGraph.h.
Definition at line 78 of file edgeGraphPart.h.
Definition at line 79 of file edgeGraphPart.h.
|
inherited |
Definition at line 271 of file nodeGraphPart.h.
|
inherited |
Definition at line 272 of file nodeGraphPart.h.