![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Classes for undirected edge sets. More...
#include <edgeGraphPart.h>
Public Attributes | |
Signaler2< NodeId, NodeId > | onEdgeAdded |
Signaler2< NodeId, NodeId > | onEdgeDeleted |
Public Member Functions | |
Constructors / Destructors | |
EdgeGraphPart (Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true) | |
default constructor More... | |
EdgeGraphPart (const EdgeGraphPart &s) | |
copy constructor More... | |
virtual | ~EdgeGraphPart () |
destructor More... | |
Operators | |
EdgeGraphPart & | operator= (const EdgeGraphPart &s) |
copy operator More... | |
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 | |
virtual void | addEdge (const NodeId n1, const NodeId n2) |
insert a new edge into the EdgeGraphPart More... | |
virtual void | eraseEdge (const Edge &edge) |
removes an edge from the EdgeGraphPart More... | |
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... | |
virtual void | clearEdges () |
removes all the edges from the EdgeGraphPart 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... | |
std::string | toString () const |
to friendly display the content of the EdgeGraphPart 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 EdgeSetIterator | EdgeIterator |
Classes for undirected edge sets.
Definition at line 74 of file edgeGraphPart.h.
Definition at line 76 of file edgeGraphPart.h.
|
explicit |
default constructor
edges_size | the size of the hash table used to store all the edges |
edges_resize_policy | the resizing policy of this hash table |
Definition at line 38 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::EdgeGraphPart::EdgeGraphPart | ( | const EdgeGraphPart & | s | ) |
copy constructor
s | the EdgeGraphPart to copy |
Definition at line 43 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
destructor
Definition at line 60 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
when the EdgeGraphPart contains no edge adjacent to a given node, this function adds an empty set entry to neighbours[id]
id | the node whose neighbours[id] is checked |
Definition at line 46 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
insert a new edge into the EdgeGraphPart
n1 | the id of one extremity of the new edge to be inserted |
n2 | the id of the other extremity of the new edge to be inserted |
Reimplemented in gum::UndiGraph, and gum::CliqueGraph.
Definition at line 50 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
removes all the edges from the EdgeGraphPart
Reimplemented in gum::CliqueGraph.
Definition at line 66 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE const EdgeSet & gum::EdgeGraphPart::edges | ( | ) | const |
returns the set of edges stored within the EdgeGraphPart
Definition at line 38 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
EdgeProperty< VAL > gum::EdgeGraphPart::edgesProperty | ( | VAL(*)(const Edge &) | f, |
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))
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. |
EdgeProperty< VAL > gum::EdgeGraphPart::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)
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. |
INLINE bool gum::EdgeGraphPart::emptyEdges | ( | ) | const |
indicates wether the EdgeGraphPart contains any edge
Definition at line 34 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
removes an edge from the EdgeGraphPart
edge | the edge to be removed |
Reimplemented in gum::CliqueGraph.
Definition at line 61 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE void gum::EdgeGraphPart::eraseNeighbours | ( | const NodeId | id | ) |
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().
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().
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().
bool gum::EdgeGraphPart::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.
n1 | NodeId |
n2 | NodeId |
except | NodeSet |
Definition at line 183 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
bool gum::EdgeGraphPart::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.
n1 | NodeSet |
n2 | NodeSet |
except | NodeSet |
Definition at line 203 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
List< VAL > gum::EdgeGraphPart::listMapEdges | ( | VAL(*)(const Edge &) | f | ) | const |
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 |
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().
INLINE bool gum::EdgeGraphPart::operator!= | ( | const EdgeGraphPart & | p | ) | const |
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().
EdgeGraphPart & gum::EdgeGraphPart::operator= | ( | const EdgeGraphPart & | s | ) |
copy operator
s | the EdgeGraphPart to copy |
Definition at line 83 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::EdgeGraphPart::operator== | ( | const EdgeGraphPart & | p | ) | const |
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().
INLINE Size gum::EdgeGraphPart::sizeEdges | ( | ) | const |
indicates the number of edges stored within the EdgeGraphPart
Definition at line 36 of file edgeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
std::string gum::EdgeGraphPart::toString | ( | ) | const |
to friendly display the content of the EdgeGraphPart
Definition at line 106 of file edgeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
const std::vector< NodeId > gum::EdgeGraphPart::undirectedPath | ( | const NodeId | node1, |
const NodeId | node2 | ||
) | const |
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().
INLINE void gum::EdgeGraphPart::unvirtualizedEraseNeighbours | ( | const NodeId | id | ) |
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 all the edges contained within the EdgeGraphPart
Definition at line 251 of file edgeGraphPart.h.
|
mutableprivate |
for each node, the set of its adjacent edges
Definition at line 254 of file edgeGraphPart.h.
Definition at line 78 of file edgeGraphPart.h.
Definition at line 79 of file edgeGraphPart.h.