![]() |
aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
|
This contains all the information we want for a node in a DFSTree. More...
#include <agrum/PRM/gspan/pattern.h>
Public Member Functions | |
Constructor and destructor. | |
Pattern () | |
Default constructor. More... | |
Pattern (const Pattern &source) | |
Copy constructor. More... | |
~Pattern () | |
Destructor. More... | |
Graphical getters and setters. | |
NodeId | addNodeWithLabel (LabelData &l) |
Insert a node with the given LabelData. More... | |
LabelData & | label (NodeId node) |
Returns the LabelData assigned to node. More... | |
const LabelData & | label (NodeId node) const |
Returns the LabelData assigned to node. More... | |
LabelData & | label (NodeId i, NodeId j) |
Returns the LabelData assigned to arc. More... | |
const LabelData & | label (NodeId i, NodeId j) const |
Returns the LabelData assigned to arc. More... | |
LabelData & | label (const Arc &arc) |
Returns the LabelData assigned to arc. More... | |
const LabelData & | label (const Arc &arc) const |
Returns the LabelData assigned to arc. More... | |
LabelData & | lastAdded () |
Insert a node with the given LabelData. More... | |
const LabelData & | lastAdded () const |
Insert a node with the given LabelData. More... | |
void | addArc (NodeId i, NodeId j, LabelData &l) |
Add an arc to this Pattern. More... | |
bool | exists (NodeId id) const |
Returns true if id is a node in this Pattern. More... | |
bool | exists (NodeId tail, NodeId head) const |
Returns true if (tail, head) is an arc in this Pattern. More... | |
Size | size () const |
Returns the number of nodes in this Pattern. More... | |
Size | sizeArcs () const |
Returns the number of arcs in this Pattern. More... | |
void | rightmostPath (std::list< NodeId > &r_path) const |
Fill r_path with the rightmost path of this Pattern. The list is supposed empty. More... | |
std::string | toDot (size_t name) const |
Print the pattern in the DOT syntax. More... | |
Access to topology | |
const NodeGraphPart & | nodes () const |
const ArcSet & | arcs () const |
DFSCode related methods. | |
DFSCode & | code () |
Returns the DFSCode of this Pattern. More... | |
const DFSCode & | code () const |
Returns the DFSCode of this Pattern. More... | |
EdgeCode & | edgeCode (NodeId tail, NodeId head) |
Returns the EdgeCode of an edge of this Pattern. More... | |
EdgeCode & | edgeCode (const Arc &arc) |
Returns the EdgeCode of an edge of this Pattern. More... | |
const EdgeCode & | edgeCode (NodeId tail, NodeId head) const |
Returns the EdgeCode of an edge of this Pattern. More... | |
const EdgeCode & | edgeCode (const Arc &arc) const |
Returns the EdgeCode of an edge of this Pattern. More... | |
void | pop_back () |
Remove the last EdgeCode of this pattern. More... | |
void | remove (NodeId node) |
Remove a node if it has no neighbors, raise an OperationNotAllowed otherwise. More... | |
bool | isMinimal () |
Returns the DFSCode of this Pattern. More... | |
This contains all the information we want for a node in a DFSTree.
Several rules are used regarding nodes in Pattern::graph. First nodes are added respecting a depth-first search, thus each node is labelled from 1 to n, where n is the number of nodes in Pattern::graph.
Given two nodes id i and j, if i < j then i was discovered before j in the depth first search.
To retrieve the depth first search tree from Pattern::graph simple consider only arcs (u, v) with u < v. The set of arcs { (u,v) | u < v} is called the forward edge set and the set of arcs { (u,v) | u > v} is called the backward edge set.
The orientation in Pattern::graph is only used to differentiate forward edges from backward edges.
|
inherited |
Definition at line 80 of file arcGraphPart.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.
INLINE gum::prm::gspan::Pattern::Pattern | ( | ) |
Default constructor.
Definition at line 34 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
gum::prm::gspan::Pattern::Pattern | ( | const Pattern & | source | ) |
Copy constructor.
Definition at line 39 of file pattern.cpp.
References gum::prm::gspan::operator<<().
INLINE gum::prm::gspan::Pattern::~Pattern | ( | ) |
Destructor.
Definition at line 37 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Add an arc to this Pattern.
This create an EdgeCode and check if it respects neighborhood restriction, if not an exception is raised.
i | The DFS subscript of the first node in the code. |
j | The DFS subscript of the second node in the code. |
l | The label data of the added edge. |
OperationNotAllowed | Raised if the neighborhood restriction is not respected. |
Definition at line 117 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
insert a new arc into the directed graph
tail | the id of the tail of the new inserted arc |
head | the id of the head of the new inserted arc |
InvalidNode | if head or tail does not belong to the graph nodes |
Reimplemented from gum::ArcGraphPart.
Reimplemented in gum::DAG.
Definition at line 34 of file diGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
insert a new node and return its id
Reimplemented in gum::CliqueGraph.
Definition at line 252 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
insert n nodes
n | the number of nodes to add |
Definition at line 270 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().
Insert a node with the given LabelData.
Definition at line 40 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
returns the set of nodes with directed path ingoing to a given node
Note that the set of nodes returned may be empty if no path within the ArcGraphPart is ingoing to the given node.
id | the node which is the head of a directed path with the returned nodes |
Definition at line 172 of file arcGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE const ArcSet & gum::prm::gspan::Pattern::arcs | ( | ) | const |
Definition at line 169 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
|
inherited |
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. |
|
inherited |
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. |
|
inherited |
returns a copy of the set of nodes represented by the NodeGraphPart
Definition at line 360 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 332 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 318 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 307 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns the set of children of a set of nodes
Definition at line 68 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
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 91 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
removes all the nodes and arcs from the graph
Reimplemented from gum::NodeGraphPart.
Reimplemented in gum::MixedGraph.
Definition at line 42 of file diGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
removes all the arcs from the ArcGraphPart
Definition at line 78 of file arcGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
remove all the nodes from the NodeGraphPart
Definition at line 309 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE DFSCode & gum::prm::gspan::Pattern::code | ( | ) |
Returns the DFSCode of this Pattern.
Definition at line 172 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
INLINE const DFSCode & gum::prm::gspan::Pattern::code | ( | ) | const |
Returns the DFSCode of this Pattern.
Definition at line 175 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
returns the set of nodes with directed path outgoing from a given node
Note that the set of nodes returned may be empty if no path within the ArcGraphPart is outgoing from the given node.
id | the node which is the tail of a directed path with the returned nodes |
Definition at line 154 of file arcGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
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 190 of file arcGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
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 231 of file arcGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
Returns the EdgeCode of an edge of this Pattern.
Definition at line 178 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the EdgeCode of an edge of this Pattern.
Definition at line 185 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the EdgeCode of an edge of this Pattern.
Definition at line 192 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the EdgeCode of an edge of this Pattern.
Definition at line 199 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
|
inherited |
alias for emptyNodes
Definition at line 305 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
indicates wether the ArcGraphPart contains any arc
Definition at line 34 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
indicates whether there exists nodes in the NodeGraphPart
Definition at line 303 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 338 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 328 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
removes an arc from the ArcGraphPart
arc | the arc to be removed |
Definition at line 108 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
removes all the children of a given node
id | the node all the children of which will be removed |
Definition at line 139 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
remove a node and its adjacent arcs from the graph
id | the id of the node to be removed |
Reimplemented from gum::NodeGraphPart.
Reimplemented in gum::MixedGraph.
Definition at line 68 of file diGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
erase all the parents of a given node
id | the node all the parents of which will be removed |
Definition at line 125 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedinherited |
a (virtualized) function to remove a given set of arcs
Definition at line 120 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
Returns true if id is a node in this Pattern.
Definition at line 138 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns true if (tail, head) is an arc in this Pattern.
Definition at line 141 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
indicates whether a given arc exists
arc | the arc we test whether or not it belongs to the ArcGraphPart |
Definition at line 40 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
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 44 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns true iff the NodeGraphPart contains the given nodeId
Definition at line 285 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
Returns true if the expand code by adding and edge betwenne u and v is minimal with respect to code__.
Definition at line 99 of file pattern.cpp.
References gum::prm::gspan::operator<<().
returns the set of nodes which consists in the node and its parents
Note that the set of nodes returned may be empty if no path within the ArcGraphPart is outgoing from the given node.
id | the node which is the tail of a directed path with the returned nodes |
Definition at line 61 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns the set of family nodes of a set of nodes
Definition at line 84 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
checks whether there exists a directed path from from to to
If from==to, this function checks if a directed cycle containing from exists.
from | |
to |
Definition at line 136 of file diGraph.cpp.
References gum::Set< Key, Alloc >::emplace().
bool gum::prm::gspan::Pattern::isMinimal | ( | ) |
Returns the DFSCode of this Pattern.
Definition at line 56 of file pattern.cpp.
References gum::prm::gspan::operator<<().
Returns the LabelData assigned to node.
Definition at line 49 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the LabelData assigned to node.
Definition at line 58 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the LabelData assigned to arc.
Definition at line 81 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the LabelData assigned to arc.
Definition at line 90 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the LabelData assigned to arc.
Definition at line 99 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
Returns the LabelData assigned to arc.
Definition at line 108 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
INLINE LabelData & gum::prm::gspan::Pattern::lastAdded | ( | ) |
Insert a node with the given LabelData.
Definition at line 67 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
INLINE const LabelData & gum::prm::gspan::Pattern::lastAdded | ( | ) | const |
Insert a node with the given LabelData.
Definition at line 74 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
|
inherited |
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 |
|
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 |
|
inherited |
returns a new node id, not yet used by any node
Definition at line 225 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE const NodeGraphPart & gum::prm::gspan::Pattern::nodes | ( | ) | const |
Definition at line 165 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
|
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. |
|
private |
A non recursive bugged version of rec__.
Definition at line 189 of file pattern.cpp.
References gum::prm::gspan::operator<<().
|
inherited |
tests whether two ArcGraphParts contain different arcs
p | the ArcGraphPart that we compare with this |
Definition at line 186 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
tests whether two DiGraphs are different
g | the DiGraph with which "this" is compared |
Definition at line 82 of file diGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
check whether two NodeGraphParts contain different nodes
p | the NodeGraphPart to be compared with "this" |
Definition at line 356 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
tests whether two ArcGraphParts contain the same arcs
p | the ArcGraphPart that we compare with this |
Definition at line 182 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
tests whether two DiGraphs are identical (same nodes, same arcs)
g | the DiGraph with which "this" is compared |
Definition at line 78 of file diGraph_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
check whether two NodeGraphParts contain the same nodes
p | the NodeGraphPart to be compared with "this" |
Definition at line 342 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
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 56 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns the set of parents of a set of nodes
Definition at line 76 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE void gum::prm::gspan::Pattern::pop_back | ( | ) |
Remove the last EdgeCode of this pattern.
Definition at line 206 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
|
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.
|
private |
Recurisve method used by expandCodeIsMinimal__.
Definition at line 128 of file pattern.cpp.
References gum::prm::gspan::operator<<().
INLINE void gum::prm::gspan::Pattern::remove | ( | NodeId | node | ) |
Remove a node if it has no neighbors, raise an OperationNotAllowed otherwise.
Definition at line 224 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
INLINE void gum::prm::gspan::Pattern::rightmostPath | ( | std::list< NodeId > & | r_path | ) | const |
Fill r_path with the rightmost path of this Pattern. The list is supposed empty.
Definition at line 152 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
INLINE Size gum::prm::gspan::Pattern::size | ( | ) | const |
Returns the number of nodes in this Pattern.
Definition at line 146 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
INLINE Size gum::prm::gspan::Pattern::sizeArcs | ( | ) | const |
Returns the number of arcs in this Pattern.
Definition at line 149 of file pattern_inl.h.
References gum::prm::gspan::operator<<().
|
inherited |
returns the number of nodes in the NodeGraphPart
Definition at line 279 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
std::string gum::prm::gspan::Pattern::toDot | ( | size_t | name | ) | const |
Print the pattern in the DOT syntax.
Definition at line 86 of file pattern.cpp.
References gum::prm::gspan::operator<<().
|
virtualinherited |
to friendly display the content of the graph in the DOT syntax
name | The graph name in the dot syntax. Default is G. |
Reimplemented in gum::MixedGraph.
Definition at line 67 of file diGraph.cpp.
References gum::Set< Key, Alloc >::emplace().
The topological order stays the same as long as no variable or arcs are added or erased src the topology.
clear | If false returns the previously created topology. |
InvalidDirectedCycle | Raised if this DiGraph contains cycles. |
Definition at line 90 of file diGraph.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
to friendly display the content of the graph
Reimplemented from gum::NodeGraphPart.
Reimplemented in gum::MixedGraph.
Definition at line 60 of file diGraph.cpp.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
same function as eraseChildren but without any virtual call to an erase
id | the node whose outgoing arcs will be removed |
Definition at line 170 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
same function as eraseParents but without any virtual call to an erase
id | the node whose ingoing arcs will be removed |
Definition at line 158 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedinherited |
similar to eraseSetOfArcs_ except that it is unvirtualized
Definition at line 153 of file arcGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
|
private |
|
private |
|
private |
Definition at line 82 of file arcGraphPart.h.
Definition at line 83 of file arcGraphPart.h.
|
inherited |
Definition at line 271 of file nodeGraphPart.h.
|
inherited |
Definition at line 272 of file nodeGraphPart.h.