61 for (
NodeId node = 1; node <= source.
size(); ++node) {
65 for (
const auto& edge: source.
code().
codes)
68 const_cast< LabelData&
>(source.
label(node_map[edge->i], node_map[edge->j])));
72 for (
const auto node:
nodes()) {
73 for (
const auto next:
parents(node)) {
78 if (edge_code < *(
code().codes.front())) {
80 }
else if (edge_code == (*
code().codes.front())) {
85 for (
const auto next:
children(node)) {
90 if (edge_code < *(
code().codes.front())) {
92 }
else if (edge_code == (*
code().codes.front())) {
102 std::stringstream sBuff;
103 sBuff <<
"digraph " << name <<
" {\n";
105 for (
const auto& arc:
arcs()) {
106 sBuff <<
label(arc.tail()).
id <<
" -> ";
107 sBuff <<
label(arc.head()).
id <<
";\n";
126 if (
_rec_(p, node_map, u, nei))
return true;
128 for (
const auto nei:
parents(u))
130 if (
_rec_(p, node_map, u, nei))
return true;
134 if (
_rec_(p, node_map, v, nei))
return true;
136 for (
const auto nei:
parents(v))
138 if (
_rec_(p, node_map, v, nei))
return true;
161 data = &(
label(u, v));
178 if (
size_t depth = p.
code().
codes.size() - 1;
181 }
else if (*(p.
code().
codes.back()) == *(
code().codes[depth])) {
182 std::list< NodeId > r_path;
185 for (
const auto node: r_path) {
187 if (
_rec_(p, node_map, node_map.
first(node), nei))
return true;
190 if (
_rec_(p, node_map, node_map.
first(node), nei))
return true;
204 std::vector< std::pair< NodeId, NodeId > > stack;
205 stack.emplace_back(a_u, a_v);
209 while (!stack.empty()) {
211 u = stack.back().first;
212 v = stack.back().second;
215 if ((u == 0) && (v == 0)) {
236 data = &(
label(u, v));
254 if (
size_t depth = p.
code().
codes.size() - 1;
257 }
else if (*(p.
code().
codes.back()) == *(
code().codes[depth])) {
258 std::list< NodeId > r_path;
262 for (
const auto node: r_path) {
263 for (
const auto nei:
children(node)) {
264 stack.emplace_back(node_map.
first(node), nei);
267 for (
const auto nei:
parents(node)) {
268 stack.emplace_back(node_map.
first(node), nei);
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
const NodeSet & parents(NodeId id) const
returns the set of nodes with arc ingoing to a given node
NodeSet children(const NodeSet &ids) const
returns the set of children of a set of nodes
void eraseFirst(const T1 &first)
Erases an association containing the given first element.
bool existsFirst(const T1 &first) const
Returns true if first is the first element in a pair in the gum::Bijection.
void insert(const T1 &first, const T2 &second)
Inserts a new association in the gum::Bijection.
const T1 & first(const T2 &second) const
Returns the first value of a pair given its second value.
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
Set of pairs of elements with fast search for both elements.
DiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
bool _expandCodeIsMinimal_(NodeId u, NodeId v)
Returns true if the expand code by adding and edge betwenne u and v is minimal with respect to code.
void rightmostPath(std::list< NodeId > &r_path) const
Fill r_path with the rightmost path of this Pattern. The list is supposed empty.
const ArcSet & arcs() const
bool isMinimal()
Returns the DFSCode of this Pattern.
NodeId addNodeWithLabel(LabelData &l)
Insert a node with the given LabelData.
Size size() const
Returns the number of nodes in this Pattern.
virtual std::string toDot() const
to friendly display the content of the graph in the DOT syntax
void pop_back()
Remove the last EdgeCode of this pattern.
DFSCode & code()
Returns the DFSCode of this Pattern.
Pattern()
Default constructor.
void remove(NodeId node)
Remove a node if it has no neighbors, raise an OperationNotAllowed otherwise.
void addArc(NodeId i, NodeId j, LabelData &l)
Add an arc to this Pattern.
const NodeGraphPart & nodes() const
bool _rec_(Pattern &p, Bijection< NodeId, NodeId > &node_map, NodeId u, NodeId v)
Recurisve method used by expandCodeIsMinimal.
LabelData & label(NodeId node)
Returns the LabelData assigned to node.
bool _not_rec_(Pattern &p, Bijection< NodeId, NodeId > &node_map, NodeId u, NodeId v)
A non recursive bugged version of rec.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Headers of the Pattern class.
Inline implementation of the Pattern class.
represent a DFS code used by gspan.
Inner class to handle data about labels in this interface graph.
Idx id
An unique identifier for this label.