![]() |
aGrUM
0.16.0
|
Classes for directed edge sets. More...
#include <arcGraphPart.h>
Public Attributes | |
Signaler2< NodeId, NodeId > | onArcAdded |
Signaler2< NodeId, NodeId > | onArcDeleted |
Public Member Functions | |
Constructors / Destructors | |
ArcGraphPart (Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true) | |
default constructor More... | |
ArcGraphPart (const ArcGraphPart &s) | |
copy constructor More... | |
virtual | ~ArcGraphPart () |
destructor More... | |
Operators | |
ArcGraphPart & | operator= (const ArcGraphPart &s) |
copy operator More... | |
bool | operator== (const ArcGraphPart &p) const |
tests whether two ArcGraphParts contain the same arcs More... | |
bool | operator!= (const ArcGraphPart &p) const |
tests whether two ArcGraphParts contain different arcs More... | |
Accessors/Modifiers | |
virtual void | addArc (const NodeId tail, const NodeId head) |
insert a new arc into the ArcGraphPart More... | |
virtual void | eraseArc (const Arc &arc) |
removes an arc from the ArcGraphPart More... | |
bool | existsArc (const Arc &arc) const |
indicates whether a given arc exists More... | |
bool | existsArc (const NodeId tail, const NodeId head) const |
indicates whether a given arc exists More... | |
bool | emptyArcs () const |
indicates wether the ArcGraphPart contains any arc More... | |
void | clearArcs () |
removes all the arcs from the ArcGraphPart More... | |
Size | sizeArcs () const |
indicates the number of arcs stored within the ArcGraphPart More... | |
const ArcSet & | arcs () const |
returns the set of arcs stored within the ArcGraphPart More... | |
const NodeSet & | parents (const NodeId id) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | children (const NodeId id) const |
returns the set of nodes with arc outgoing from a given node More... | |
void | eraseParents (const NodeId id) |
erase all the parents of a given node More... | |
void | unvirtualizedEraseParents (const NodeId id) |
same function as eraseParents but without any virtual call to an erase More... | |
void | eraseChildren (const NodeId id) |
removes all the children of a given node More... | |
void | unvirtualizedEraseChildren (const NodeId id) |
same function as eraseChildren but without any virtual call to an erase More... | |
const std::string | toString () const |
to friendly display the content of the ArcGraphPart More... | |
template<typename VAL > | |
ArcProperty< VAL > | arcsProperty (VAL(*f)(const Arc &), Size size=0) const |
a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL f(x)) More... | |
template<typename VAL > | |
ArcProperty< VAL > | arcsProperty (const VAL &a, Size size=0) const |
a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL a) More... | |
template<typename VAL > | |
List< VAL > | listMapArcs (VAL(*f)(const Arc &)) const |
a method to create a list of VAL from a set of arcs (using for every arc, say x, the VAL f(x)) More... | |
const std::vector< NodeId > | directedPath (const NodeId node1, const NodeId node2) const |
returns a directed path from node1 to node2 belonging to the set of arcs More... | |
const std::vector< NodeId > | directedUnorientedPath (const NodeId node1, const NodeId node2) const |
returns an unoriented (directed) path from node1 to node2 in the arc set More... | |
Public Types | |
typedef ArcSetIterator | ArcIterator |
Protected Member Functions | |
void | _eraseSetOfArcs (const ArcSet &set) |
a (virtualized) function to remove a given set of arcs More... | |
void | _unvirtualizedEraseSetOfArcs (const ArcSet &set) |
similar to _eraseSetOfArcs except that it is unvirtualized More... | |
Classes for directed edge sets.
Definition at line 79 of file arcGraphPart.h.
Definition at line 81 of file arcGraphPart.h.
|
explicit |
default constructor
arcs_size | the size of the hash table used to store all the arcs |
arcs_resize_policy | the resizing policy of this hash table |
Definition at line 39 of file arcGraphPart.cpp.
gum::ArcGraphPart::ArcGraphPart | ( | const ArcGraphPart & | s | ) |
copy constructor
s | the ArcGraphPart to copy |
Definition at line 44 of file arcGraphPart.cpp.
References __arcs, __children, __parents, gum::HashTable< Key, Val, Alloc >::capacity(), children(), GUM_EMIT2, and onArcAdded.
|
virtual |
destructor
Definition at line 73 of file arcGraphPart.cpp.
References clearArcs().
|
private |
when the ArcGraphPart contains no arc outgoing from a given node, this function adds an empty set entry to __children[id]
id | the node whose __children[id] is checked |
Definition at line 53 of file arcGraphPart_inl.h.
References __children.
Referenced by addArc(), and children().
|
private |
when the ArcGraphPart contains no arc ingoing into a given node, this function adds an empty set entry to __parents[id]
id | the node whose __parents[id] is checked |
Definition at line 49 of file arcGraphPart_inl.h.
References __parents.
Referenced by addArc(), and parents().
|
protected |
a (virtualized) function to remove a given set of arcs
Definition at line 91 of file arcGraphPart_inl.h.
References eraseArc().
|
protected |
similar to _eraseSetOfArcs except that it is unvirtualized
Definition at line 124 of file arcGraphPart_inl.h.
References eraseArc().
insert a new arc into the ArcGraphPart
tail | the id of the tail of the new arc to be inserted |
head | the id of the head of the new arc to be inserted |
Reimplemented in gum::DiGraph, and gum::DAG.
Definition at line 67 of file arcGraphPart_inl.h.
References __arcs, __checkChildren(), __checkParents(), __children, __parents, GUM_EMIT2, gum::Set< Key, Alloc >::insert(), and onArcAdded.
Referenced by gum::DiGraph::addArc().
INLINE const ArcSet & gum::ArcGraphPart::arcs | ( | ) | const |
returns the set of arcs stored within the ArcGraphPart
Definition at line 39 of file arcGraphPart_inl.h.
References __arcs.
Referenced by gum::MarkovBlanket::arcs(), gum::EssentialGraph::arcs(), gum::DAGmodel::arcs(), gum::prm::gspan::Pattern::arcs(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::DAG::moralGraph(), and gum::DiGraph::toDot().
ArcProperty< VAL > gum::ArcGraphPart::arcsProperty | ( | VAL(*)(const Arc &) | f, |
Size | size = 0 |
||
) | const |
a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL f(x))
f | a function assigning a VAL to any arc |
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 arcs. If you do not specify this parameter, the method will assign it for you. |
ArcProperty< VAL > gum::ArcGraphPart::arcsProperty | ( | const VAL & | a, |
Size | size = 0 |
||
) | const |
a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL a)
a | the default value assigned to each arc 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 arcs. If you do not specify this parameter, the method will assign it for you. |
returns the set of nodes with arc outgoing from a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is outgoing from the given node.
id | the node which is the tail of the arcs returned |
Definition at line 62 of file arcGraphPart_inl.h.
References __checkChildren(), and __children.
Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::EssentialGraph::__buildEssentialGraph(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::prm::gspan::Pattern::__expandCodeIsMinimal(), gum::prm::gspan::Pattern::__not_rec(), gum::prm::gspan::Pattern::__rec(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_initialize(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_makeInferenceNodeToNeighbours(), ArcGraphPart(), gum::MarkovBlanket::children(), gum::EssentialGraph::children(), gum::DAGmodel::children(), directedUnorientedPath(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), eraseChildren(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::DiGraph::hasDirectedPath(), gum::prm::gspan::Pattern::isMinimal(), gum::MixedGraph::mixedUnorientedPath(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::prm::gspan::Pattern::remove(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::MarkovBlanket::toDot(), gum::EssentialGraph::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MixedGraph::toDot(), and unvirtualizedEraseChildren().
void gum::ArcGraphPart::clearArcs | ( | ) |
removes all the arcs from the ArcGraphPart
Definition at line 79 of file arcGraphPart.cpp.
References __arcs, __children, __parents, gum::Set< Key, Alloc >::clear(), GUM_EMIT2, and onArcDeleted.
Referenced by gum::DiGraph::clear(), gum::MixedGraph::clear(), operator=(), gum::MixedGraph::operator=(), and ~ArcGraphPart().
const std::vector< NodeId > gum::ArcGraphPart::directedPath | ( | const NodeId | node1, |
const NodeId | node2 | ||
) | const |
returns a directed path from node1 to node2 belonging to the set of arcs
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 155 of file arcGraphPart.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(), parents(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().
Referenced by gum::learning::Miic::_orientation_latents().
const std::vector< NodeId > gum::ArcGraphPart::directedUnorientedPath | ( | const NodeId | node1, |
const NodeId | node2 | ||
) | const |
returns an unoriented (directed) path from node1 to node2 in the arc 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 198 of file arcGraphPart.cpp.
References children(), gum::List< Val, Alloc >::empty(), gum::HashTable< Key, Val, Alloc >::exists(), gum::List< Val, Alloc >::front(), GUM_ERROR, gum::HashTable< Key, Val, Alloc >::insert(), parents(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().
INLINE bool gum::ArcGraphPart::emptyArcs | ( | ) | const |
indicates wether the ArcGraphPart contains any arc
Definition at line 35 of file arcGraphPart_inl.h.
References __arcs, and gum::Set< Key, Alloc >::empty().
|
virtual |
removes an arc from the ArcGraphPart
arc | the arc to be removed |
Definition at line 79 of file arcGraphPart_inl.h.
References __arcs, __children, __parents, gum::Set< Key, Alloc >::erase(), existsArc(), GUM_EMIT2, gum::Arc::head(), onArcDeleted, and gum::Arc::tail().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::prm::LayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::learning::genericBNLearner::__learnDAG(), _eraseSetOfArcs(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), _unvirtualizedEraseSetOfArcs(), gum::DAGCycleDetector::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), eraseChildren(), eraseParents(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::prm::gspan::Pattern::pop_back(), gum::BayesNet< double >::reverseArc(), unvirtualizedEraseChildren(), and unvirtualizedEraseParents().
INLINE void gum::ArcGraphPart::eraseChildren | ( | const NodeId | id | ) |
removes all the children of a given node
id | the node all the children of which will be removed |
Definition at line 110 of file arcGraphPart_inl.h.
References __children, gum::Set< Key, Alloc >::beginSafe(), children(), gum::Set< Key, Alloc >::endSafe(), and eraseArc().
INLINE void gum::ArcGraphPart::eraseParents | ( | const NodeId | id | ) |
erase all the parents of a given node
id | the node all the parents of which will be removed |
Definition at line 96 of file arcGraphPart_inl.h.
References __parents, gum::Set< Key, Alloc >::beginSafe(), gum::Set< Key, Alloc >::endSafe(), eraseArc(), and parents().
indicates whether a given arc exists
arc | the arc we test whether or not it belongs to the ArcGraphPart |
Definition at line 41 of file arcGraphPart_inl.h.
References __arcs, and gum::Set< Key, Alloc >::contains().
Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AorR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MarkovBlanket::__buildMarkovBlanket(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::learning::Miic::__existsDirectedPath(), gum::prm::LayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_multi(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__jump_poly(), gum::prm::gspan::Pattern::__not_rec(), gum::prm::gspan::Pattern::__rec(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::learning::Miic::_updateProbaTriples(), gum::DAGCycleDetector::addArc(), eraseArc(), gum::DAGCycleDetector::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), and gum::prm::gspan::Pattern::exists().
indicates whether a given arc exists
tail | the tail of the arc we test the existence in the ArcGraphPart |
head | the head of the arc we test the existence in the ArcGraphPart |
Definition at line 45 of file arcGraphPart_inl.h.
References __parents.
a method to create a list of VAL from a set of arcs (using for every arc, say x, the VAL f(x))
f | a function assigning a VAL to any arc |
INLINE bool gum::ArcGraphPart::operator!= | ( | const ArcGraphPart & | p | ) | const |
tests whether two ArcGraphParts contain different arcs
p | the ArcGraphPart that we compare with this |
Definition at line 157 of file arcGraphPart_inl.h.
References __arcs.
ArcGraphPart & gum::ArcGraphPart::operator= | ( | const ArcGraphPart & | s | ) |
copy operator
s | the ArcGraphPart to copy |
Definition at line 102 of file arcGraphPart.cpp.
References __arcs, __children, __parents, clearArcs(), GUM_EMIT2, and onArcAdded.
Referenced by gum::DiGraph::operator=(), and gum::MixedGraph::operator=().
INLINE bool gum::ArcGraphPart::operator== | ( | const ArcGraphPart & | p | ) | const |
tests whether two ArcGraphParts contain the same arcs
p | the ArcGraphPart that we compare with this |
Definition at line 153 of file arcGraphPart_inl.h.
References __arcs.
Referenced by gum::DiGraph::operator==(), and gum::MixedGraph::operator==().
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 57 of file arcGraphPart_inl.h.
References __checkParents(), and __parents.
Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::learning::Miic::__existsDirectedPath(), gum::prm::gspan::Pattern::__expandCodeIsMinimal(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateClass(), gum::prm::LayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::prm::LayerGenerator< GUM_SCALAR >::__generateClasses(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateCluster(), gum::prm::gspan::Pattern::__not_rec(), gum::prm::gspan::Pattern::__rec(), gum::EssentialGraph::__strongly_protected(), gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_initialize(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_makeInferenceNodeToNeighbours(), gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::learning::Miic::_orientation_miic(), gum::learning::Miic::_propagatesHead(), gum::BarrenNodesFinder::barrenNodes(), directedPath(), directedUnorientedPath(), gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples(), eraseParents(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::prm::gspan::Pattern::isMinimal(), gum::learning::Miic::learnStructure(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), gum::DAG::moralGraph(), gum::prm::gspan::DFSTree< GUM_SCALAR >::parent(), gum::MarkovBlanket::parents(), gum::EssentialGraph::parents(), gum::DAGmodel::parents(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::prm::gspan::Pattern::remove(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::prm::gspan::Pattern::rightmostPath(), and unvirtualizedEraseParents().
INLINE Size gum::ArcGraphPart::sizeArcs | ( | ) | const |
indicates the number of arcs stored within the ArcGraphPart
Definition at line 37 of file arcGraphPart_inl.h.
References __arcs, and gum::Set< Key, Alloc >::size().
Referenced by gum::MarkovBlanket::sizeArcs(), gum::EssentialGraph::sizeArcs(), gum::DAGmodel::sizeArcs(), gum::prm::gspan::Pattern::sizeArcs(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
const std::string gum::ArcGraphPart::toString | ( | ) | const |
to friendly display the content of the ArcGraphPart
Definition at line 135 of file arcGraphPart.cpp.
References __arcs.
Referenced by gum::DiGraph::toString(), and gum::MixedGraph::toString().
INLINE void gum::ArcGraphPart::unvirtualizedEraseChildren | ( | const NodeId | id | ) |
same function as eraseChildren but without any virtual call to an erase
id | the node whose outgoing arcs will be removed |
Definition at line 141 of file arcGraphPart_inl.h.
References __children, gum::Set< Key, Alloc >::beginSafe(), children(), gum::Set< Key, Alloc >::endSafe(), and eraseArc().
Referenced by gum::DiGraph::eraseNode(), and gum::MixedGraph::eraseNode().
INLINE void gum::ArcGraphPart::unvirtualizedEraseParents | ( | const NodeId | id | ) |
same function as eraseParents but without any virtual call to an erase
id | the node whose ingoing arcs will be removed |
Definition at line 129 of file arcGraphPart_inl.h.
References __parents, gum::Set< Key, Alloc >::beginSafe(), gum::Set< Key, Alloc >::endSafe(), eraseArc(), and parents().
Referenced by gum::DiGraph::eraseNode(), and gum::MixedGraph::eraseNode().
the set of all the arcs contained within the ArcGraphPart
Definition at line 269 of file arcGraphPart.h.
Referenced by addArc(), ArcGraphPart(), arcs(), clearArcs(), emptyArcs(), eraseArc(), existsArc(), operator!=(), operator=(), operator==(), sizeArcs(), and toString().
|
mutableprivate |
for each arc, the set of its children
Definition at line 275 of file arcGraphPart.h.
Referenced by __checkChildren(), addArc(), ArcGraphPart(), children(), clearArcs(), eraseArc(), eraseChildren(), operator=(), and unvirtualizedEraseChildren().
|
mutableprivate |
for each arc, the sets of its parents
Definition at line 272 of file arcGraphPart.h.
Referenced by __checkParents(), addArc(), ArcGraphPart(), clearArcs(), eraseArc(), eraseParents(), existsArc(), operator=(), parents(), and unvirtualizedEraseParents().
Definition at line 83 of file arcGraphPart.h.
Referenced by addArc(), ArcGraphPart(), and operator=().
Definition at line 84 of file arcGraphPart.h.
Referenced by clearArcs(), and eraseArc().