![]() |
aGrUM
0.16.0
|
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 edges adjacent 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... | |
const 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... | |
Public Types | |
typedef EdgeSetIterator | EdgeIterator |
Classes for undirected edge sets.
Definition at line 75 of file edgeGraphPart.h.
Definition at line 77 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 39 of file edgeGraphPart.cpp.
gum::EdgeGraphPart::EdgeGraphPart | ( | const EdgeGraphPart & | s | ) |
copy constructor
s | the EdgeGraphPart to copy |
Definition at line 44 of file edgeGraphPart.cpp.
References __edges, __neighbours, GUM_EMIT2, and onEdgeAdded.
|
virtual |
destructor
Definition at line 61 of file edgeGraphPart.cpp.
References clearEdges().
|
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 50 of file edgeGraphPart_inl.h.
References __neighbours.
Referenced by addEdge(), and neighbours().
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 54 of file edgeGraphPart_inl.h.
References __checkNeighbours(), __edges, __neighbours, GUM_EMIT2, gum::Set< Key, Alloc >::insert(), and onEdgeAdded.
Referenced by gum::UndiGraph::addEdge().
|
virtual |
removes all the edges from the EdgeGraphPart
Reimplemented in gum::CliqueGraph.
Definition at line 67 of file edgeGraphPart.cpp.
References __edges, __neighbours, gum::Set< Key, Alloc >::clear(), GUM_EMIT2, and onEdgeDeleted.
Referenced by gum::UndiGraph::clear(), gum::MixedGraph::clear(), operator=(), gum::MixedGraph::operator=(), and ~EdgeGraphPart().
INLINE const EdgeSet & gum::EdgeGraphPart::edges | ( | ) | const |
returns the set of edges stored within the EdgeGraphPart
Definition at line 39 of file edgeGraphPart_inl.h.
References __edges.
Referenced by gum::StaticTriangulation::__computeMaxPrimeJunctionTree(), gum::learning::Miic::_initiation(), gum::BarrenNodesFinder::barrenNodes(), gum::EssentialGraph::edges(), gum::SpanningForestPrim::edgesInSpanningForest(), and gum::learning::genericBNLearner::setPossibleSkeleton().
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. |
Referenced by gum::DefaultJunctionTreeStrategy::__computeJunctionTree().
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 35 of file edgeGraphPart_inl.h.
References __edges, and gum::Set< Key, Alloc >::empty().
|
virtual |
removes an edge from the EdgeGraphPart
edge | the edge to be removed |
Reimplemented in gum::CliqueGraph.
Definition at line 65 of file edgeGraphPart_inl.h.
References __edges, __neighbours, gum::Set< Key, Alloc >::erase(), existsEdge(), gum::Edge::first(), GUM_EMIT2, onEdgeDeleted, and gum::Edge::second().
Referenced by gum::learning::Miic::_initiation(), gum::learning::Miic::_iteration(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::learning::Miic::_propagatesHead(), eraseNeighbours(), and unvirtualizedEraseNeighbours().
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 83 of file edgeGraphPart_inl.h.
References __neighbours, eraseEdge(), and neighbours().
indicates whether a given edge exists
edge | the edge we test whether or not it belongs to the EdgeGraphPart |
Definition at line 41 of file edgeGraphPart_inl.h.
References __edges, and gum::Set< Key, Alloc >::contains().
Referenced by gum::StaticTriangulation::__computeMaxPrimeMergings(), gum::prm::GSpan< GUM_SCALAR >::__sortPatterns(), gum::EssentialGraph::__strongly_protected(), gum::StaticTriangulation::__triangulate(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_miic(), eraseEdge(), gum::StaticTriangulation::fillIns(), and gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::InterfaceGraph().
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 45 of file edgeGraphPart_inl.h.
References __neighbours.
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 edges adjacent to a given node
Note that the set of edges 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 78 of file edgeGraphPart_inl.h.
References __checkNeighbours(), and __neighbours.
Referenced by gum::DefaultJunctionTreeStrategy::__computeJunctionTree(), gum::StaticTriangulation::__computeMaxPrimeMergings(), gum::BinaryJoinTreeConverterDefault::__convertClique(), gum::BinaryJoinTreeConverterDefault::__convertConnectedComponent(), gum::SpanningForestPrim::__exploreNode(), gum::prm::gspan::DFSTree< GUM_SCALAR >::__initialiaze_root(), gum::BinaryJoinTreeConverterDefault::__markConnectedComponent(), gum::prm::StructuredInference< GUM_SCALAR >::__removeBarrenNodes(), gum::prm::GSpan< GUM_SCALAR >::__sortPatterns(), gum::EssentialGraph::__strongly_protected(), gum::StaticTriangulation::__triangulate(), gum::learning::Miic::_propagatesHead(), eraseNeighbours(), gum::prm::gspan::DFSTree< GUM_SCALAR >::growPattern(), gum::UndiGraph::hasUndirectedCycle(), gum::learning::Miic::learnStructure(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), gum::EssentialGraph::neighbours(), gum::prm::gspan::DFSTree< GUM_SCALAR >::NeighborDegreeSort::operator()(), gum::UndiGraph::partialUndiGraph(), gum::EssentialGraph::toDot(), gum::UndiGraph::toDot(), gum::MixedGraph::toDot(), undirectedPath(), and unvirtualizedEraseNeighbours().
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 111 of file edgeGraphPart_inl.h.
References __edges.
EdgeGraphPart & gum::EdgeGraphPart::operator= | ( | const EdgeGraphPart & | s | ) |
copy operator
s | the EdgeGraphPart to copy |
Definition at line 84 of file edgeGraphPart.cpp.
References __edges, __neighbours, clearEdges(), GUM_EMIT2, and onEdgeAdded.
Referenced by gum::UndiGraph::operator=(), and gum::MixedGraph::operator=().
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 107 of file edgeGraphPart_inl.h.
References __edges.
Referenced by gum::UndiGraph::operator==(), and gum::MixedGraph::operator==().
INLINE Size gum::EdgeGraphPart::sizeEdges | ( | ) | const |
indicates the number of edges stored within the EdgeGraphPart
Definition at line 37 of file edgeGraphPart_inl.h.
References __edges, and gum::Set< Key, Alloc >::size().
Referenced by gum::EssentialGraph::sizeEdges().
const std::string gum::EdgeGraphPart::toString | ( | ) | const |
to friendly display the content of the EdgeGraphPart
Definition at line 107 of file edgeGraphPart.cpp.
References __edges.
Referenced by gum::UndiGraph::toString(), and gum::MixedGraph::toString().
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 127 of file edgeGraphPart.cpp.
References gum::List< Val, Alloc >::empty(), gum::HashTable< Key, Val, Alloc >::exists(), gum::List< Val, Alloc >::front(), GUM_ERROR, gum::HashTable< Key, Val, Alloc >::insert(), neighbours(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().
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 96 of file edgeGraphPart_inl.h.
References __neighbours, eraseEdge(), and neighbours().
Referenced by gum::UndiGraph::eraseNode(), and gum::MixedGraph::eraseNode().
|
private |
the set of all the edges contained within the EdgeGraphPart
Definition at line 226 of file edgeGraphPart.h.
Referenced by addEdge(), clearEdges(), EdgeGraphPart(), edges(), emptyEdges(), eraseEdge(), existsEdge(), operator!=(), operator=(), operator==(), sizeEdges(), and toString().
|
mutableprivate |
for each node, the set of its adjacent edges
Definition at line 229 of file edgeGraphPart.h.
Referenced by __checkNeighbours(), addEdge(), clearEdges(), EdgeGraphPart(), eraseEdge(), eraseNeighbours(), existsEdge(), neighbours(), operator=(), and unvirtualizedEraseNeighbours().
Definition at line 79 of file edgeGraphPart.h.
Referenced by addEdge(), EdgeGraphPart(), and operator=().
Definition at line 80 of file edgeGraphPart.h.
Referenced by clearEdges(), and eraseEdge().