![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Classes for undirected edge sets. More...
#include <edgeGraphPart.h>
Public Types | |
| using | EdgeIterator = EdgeSetIterator |
Public Member Functions | |
Constructors / Destructors | |
| EdgeGraphPart (Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true) | |
| default constructor | |
| EdgeGraphPart (const EdgeGraphPart &s) | |
| copy constructor | |
| virtual | ~EdgeGraphPart () |
| destructor | |
Operators | |
| EdgeGraphPart & | operator= (const EdgeGraphPart &s) |
| copy operator | |
| bool | operator== (const EdgeGraphPart &p) const |
| tests whether two EdgeGraphParts contain the same edges | |
Accessors/Modifiers | |
| virtual void | addEdge (NodeId n1, NodeId n2) |
| insert a new edge into the EdgeGraphPart | |
| virtual void | eraseEdge (const Edge &edge) |
| removes an edge from the EdgeGraphPart | |
| bool | existsEdge (const Edge &edge) const |
| indicates whether a given edge exists | |
| bool | existsEdge (NodeId n1, NodeId n2) const |
| indicates whether a given edge exists | |
| bool | emptyEdges () const |
| indicates wether the EdgeGraphPart contains any edge | |
| virtual void | clearEdges () |
| removes all the edges from the EdgeGraphPart | |
| Size | sizeEdges () const |
| indicates the number of edges stored within the EdgeGraphPart | |
| const EdgeSet & | edges () const |
| returns the set of edges stored within the EdgeGraphPart | |
| const NodeSet & | neighbours (NodeId id) const |
| returns the set of node neighbours to a given node | |
| void | eraseNeighbours (NodeId id) |
| erase all the edges adjacent to a given node | |
| void | unvirtualizedEraseNeighbours (NodeId id) |
| same function as eraseNeighbours but without any virtual call to an erase | |
| virtual std::string | toString () const |
| to friendly display the content of the EdgeGraphPart | |
| 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)) | |
| template<typename VAL> | |
| EdgeProperty< VAL > | edgesProperty (const VAL &val, 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) | |
| 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)) | |
| std::vector< NodeId > | undirectedPath (NodeId node1, NodeId node2) const |
| returns a possible path from node1 to node2 in the edge set | |
| bool | hasUndirectedPath (NodeId n1, NodeId n2) const |
| return true if n1 and n2 are connected (by an undirected path) in the graph. | |
| bool | hasUndirectedPath (NodeId n1, 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. | |
| 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. | |
Public Attributes | |
| Signaler2< NodeId, NodeId > | onEdgeAdded |
| Signaler2< NodeId, NodeId > | onEdgeDeleted |
Private Member Functions | |
| void | _checkNeighbours_ (NodeId id) |
| when the EdgeGraphPart contains no edge adjacent to a given node, this function adds an empty set entry to neighbours[id] | |
| void | _clearEdges_ () |
Private Attributes | |
| EdgeSet | _edges_ |
| the set of all the edges contained within the EdgeGraphPart | |
| NodeProperty< NodeSet * > | _neighbours_ |
| for each node, the set of its adjacent edges | |
Classes for undirected edge sets.
Definition at line 94 of file edgeGraphPart.h.
Definition at line 96 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 58 of file edgeGraphPart.cpp.
References EdgeGraphPart(), and _edges_.
Referenced by EdgeGraphPart(), EdgeGraphPart(), gum::UndiGraph::UndiGraph(), gum::UndiGraph::UndiGraph(), ~EdgeGraphPart(), operator=(), and operator==().
| gum::EdgeGraphPart::EdgeGraphPart | ( | const EdgeGraphPart & | s | ) |
copy constructor
| s | the EdgeGraphPart to copy |
Definition at line 63 of file edgeGraphPart.cpp.
References EdgeGraphPart(), _edges_, _neighbours_, GUM_EMIT2, and onEdgeAdded.
|
virtual |
destructor
Definition at line 80 of file edgeGraphPart.cpp.
References EdgeGraphPart(), and _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 67 of file edgeGraphPart_inl.h.
References _neighbours_.
Referenced by addEdge().
|
private |
Definition at line 88 of file edgeGraphPart.cpp.
References _edges_, _neighbours_, GUM_EMIT2, and onEdgeDeleted.
Referenced by ~EdgeGraphPart(), and clearEdges().
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::CliqueGraph, gum::PDAG, and gum::UndiGraph.
Definition at line 71 of file edgeGraphPart_inl.h.
References _checkNeighbours_(), _edges_, _neighbours_, GUM_EMIT2, and onEdgeAdded.
Referenced by gum::PDAG::addEdge(), and gum::UndiGraph::addEdge().
|
virtual |
removes all the edges from the EdgeGraphPart
Reimplemented in gum::CliqueGraph.
Definition at line 86 of file edgeGraphPart.cpp.
References _clearEdges_().
Referenced by gum::MixedGraph::clear(), gum::UndiGraph::clear(), operator=(), and gum::MixedGraph::operator=().
| INLINE const EdgeSet & gum::EdgeGraphPart::edges | ( | ) | const |
returns the set of edges stored within the EdgeGraphPart
Definition at line 59 of file edgeGraphPart_inl.h.
References _edges_.
Referenced by gum::EssentialGraph::_buildEssentialGraph_(), gum::MeekRules::_propagatesOrientationInChainOfRemainingEdges_(), gum::BarrenNodesFinder::barrenNodes(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::PDAG::moralGraph(), gum::learning::SimpleMiic::propagatesOrientationInChainOfRemainingEdges_(), gum::MeekRules::propagateToCPDAG(), and gum::learning::IBNLearner::setPossibleSkeleton().
| EdgeProperty< VAL > gum::EdgeGraphPart::edgesProperty | ( | const VAL & | val, |
| 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. |
| EdgeProperty< VAL > gum::EdgeGraphPart::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))
| 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. |
| INLINE bool gum::EdgeGraphPart::emptyEdges | ( | ) | const |
indicates wether the EdgeGraphPart contains any edge
Definition at line 55 of file edgeGraphPart_inl.h.
References _edges_.
|
virtual |
removes an edge from the EdgeGraphPart
| edge | the edge to be removed |
Reimplemented in gum::CliqueGraph.
Definition at line 82 of file edgeGraphPart_inl.h.
References _edges_, _neighbours_, existsEdge(), gum::Edge::first(), GUM_EMIT2, onEdgeDeleted, and gum::Edge::second().
Referenced by gum::MeekRules::_applyMeekRules_(), gum::learning::Miic::_orientingVstructureMiic_(), gum::learning::SimpleMiic::_orientingVstructureMiic_(), gum::MeekRules::_propagatesOrientationInChainOfRemainingEdges_(), gum::learning::Miic::_propagatingOrientationMiic_(), gum::learning::SimpleMiic::_propagatingOrientationMiic_(), gum::prm::GSpan< GUM_SCALAR >::discoverPatterns(), eraseNeighbours(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::SimpleMiic::learnPDAG(), gum::learning::SimpleMiic::learnStructure(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), gum::learning::SimpleMiic::orientationMiic_(), gum::learning::SimpleMiic::propagatesOrientationInChainOfRemainingEdges_(), gum::learning::SimpleMiic::propagatesRemainingOrientableEdges_(), and unvirtualizedEraseNeighbours().
| INLINE void gum::EdgeGraphPart::eraseNeighbours | ( | 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 101 of file edgeGraphPart_inl.h.
References _neighbours_, gum::Set< Key >::beginSafe(), gum::Set< Key >::endSafe(), and eraseEdge().
indicates whether a given edge exists
| edge | the edge we test whether or not it belongs to the EdgeGraphPart |
Definition at line 61 of file edgeGraphPart_inl.h.
References _edges_.
Referenced by gum::prm::GSpan< GUM_SCALAR >::_sortPatterns_(), gum::EssentialGraph::_strongly_protected_(), gum::StaticTriangulation::_triangulate_(), eraseEdge(), gum::learning::Miic::orientationMiic_(), gum::learning::SimpleMiic::orientationMiic_(), gum::learning::Miic::unshieldedTriples_(), gum::learning::SimpleMiic::unshieldedTriples_(), gum::learning::Miic::unshieldedTriplesMiic_(), and gum::learning::SimpleMiic::unshieldedTriplesMiic_().
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 63 of file edgeGraphPart_inl.h.
References _neighbours_.
| 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.
Definition at line 222 of file edgeGraphPart.cpp.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::Set< Key >::insert(), and neighbours().
return true if n1 and n2 are connected (by an undirected path) in the graph.
Definition at line 185 of file edgeGraphPart.cpp.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::Set< Key >::insert(), and neighbours().
Referenced by gum::UGmodel::isIndependent(), and gum::UGmodel::isIndependent().
return true if n1 and n2 are connected (by an undirected path not using the nodes of except) in the graph.
Definition at line 202 of file edgeGraphPart.cpp.
References gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::Set< Key >::insert(), and neighbours().
| List< VAL > gum::EdgeGraphPart::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))
| 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 96 of file edgeGraphPart_inl.h.
References _neighbours_, and gum::emptyNodeSet.
Referenced by gum::MeekRules::_applyMeekRules_(), gum::BinaryJoinTreeConverterDefault::_convertClique_(), gum::BinaryJoinTreeConverterDefault::_convertConnectedComponent_(), gum::MeekRules::_critereMinParents_(), gum::BinaryJoinTreeConverterDefault::_markConnectedComponent_(), gum::MeekRules::_propagatesOrientationInChainOfRemainingEdges_(), gum::prm::StructuredInference< GUM_SCALAR >::_removeBarrenNodes_(), gum::prm::GSpan< GUM_SCALAR >::_sortPatterns_(), gum::prm::GSpan< GUM_SCALAR >::_subgraph_mining_(), gum::StaticTriangulation::_triangulate_(), gum::MixedGraph::boundary(), gum::MixedGraph::chainComponent(), gum::MixedGraph::hasMixedOrientedPath(), gum::PDAG::hasMixedReallyOrientedPath(), gum::UndiGraph::hasUndirectedCycle(), hasUndirectedPath(), hasUndirectedPath(), hasUndirectedPath(), gum::learning::SimpleMiic::learnPDAG(), gum::learning::SimpleMiic::learnStructure(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), gum::PDAG::moralGraph(), gum::UndiGraph::nodes2ConnectedComponent(), gum::UndiGraph::partialUndiGraph(), gum::learning::SimpleMiic::propagatesOrientationInChainOfRemainingEdges_(), gum::learning::SimpleMiic::propagatesRemainingOrientableEdges_(), gum::rec_ancestral(), gum::rec_hasMixedReallyOrientedPath(), gum::MixedGraph::toDot(), gum::PDAG::toDot(), gum::UndiGraph::toDot(), undirectedPath(), gum::learning::Miic::unshieldedTriples_(), gum::learning::SimpleMiic::unshieldedTriples_(), gum::learning::Miic::unshieldedTriplesMiic_(), and gum::learning::SimpleMiic::unshieldedTriplesMiic_().
| EdgeGraphPart & gum::EdgeGraphPart::operator= | ( | const EdgeGraphPart & | s | ) |
copy operator
| s | the EdgeGraphPart to copy |
Definition at line 105 of file edgeGraphPart.cpp.
References EdgeGraphPart(), _edges_, _neighbours_, clearEdges(), GUM_EMIT2, and onEdgeAdded.
Referenced by gum::MixedGraph::operator=(), and gum::UndiGraph::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 125 of file edgeGraphPart_inl.h.
References EdgeGraphPart(), and _edges_.
Referenced by gum::MixedGraph::operator==(), and gum::UndiGraph::operator==().
| INLINE Size gum::EdgeGraphPart::sizeEdges | ( | ) | const |
indicates the number of edges stored within the EdgeGraphPart
Definition at line 57 of file edgeGraphPart_inl.h.
References _edges_.
|
virtual |
to friendly display the content of the EdgeGraphPart
Reimplemented in gum::CliqueGraph, gum::MixedGraph, and gum::UndiGraph.
Definition at line 128 of file edgeGraphPart.cpp.
References _edges_.
Referenced by gum::operator<<(), gum::MixedGraph::toString(), and gum::UndiGraph::toString().
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 145 of file edgeGraphPart.cpp.
References gum::List< Val >::empty(), gum::HashTable< Key, Val >::exists(), gum::List< Val >::front(), GUM_ERROR, gum::HashTable< Key, Val >::insert(), neighbours(), gum::List< Val >::popFront(), and gum::List< Val >::pushBack().
| INLINE void gum::EdgeGraphPart::unvirtualizedEraseNeighbours | ( | 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 114 of file edgeGraphPart_inl.h.
References _neighbours_, gum::Set< Key >::beginSafe(), gum::Set< Key >::endSafe(), and eraseEdge().
Referenced by gum::MixedGraph::eraseNode(), and gum::UndiGraph::eraseNode().
|
private |
the set of all the edges contained within the EdgeGraphPart
Definition at line 266 of file edgeGraphPart.h.
Referenced by EdgeGraphPart(), EdgeGraphPart(), _clearEdges_(), addEdge(), edges(), emptyEdges(), eraseEdge(), existsEdge(), operator=(), operator==(), sizeEdges(), and toString().
|
private |
for each node, the set of its adjacent edges
Definition at line 269 of file edgeGraphPart.h.
Referenced by EdgeGraphPart(), _checkNeighbours_(), _clearEdges_(), addEdge(), eraseEdge(), eraseNeighbours(), existsEdge(), neighbours(), operator=(), and unvirtualizedEraseNeighbours().
Definition at line 98 of file edgeGraphPart.h.
Referenced by EdgeGraphPart(), addEdge(), and operator=().
Definition at line 99 of file edgeGraphPart.h.
Referenced by _clearEdges_(), and eraseEdge().