aGrUM  0.14.2
edgeGrowth_tpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
28 
29 namespace gum {
30  namespace prm {
31  namespace gspan {
32 
33  template < typename GUM_SCALAR >
35  LabelData* an_edge,
36  LabelData* a_l_v,
37  NodeId a_v) :
38  u(a_u),
39  edge(an_edge), l_v(a_l_v), v(a_v),
40  degree_list(new std::vector< NodeId >()) {
41  GUM_CONSTRUCTOR(EdgeGrowth);
42  }
43 
44  template < typename GUM_SCALAR >
46  const EdgeGrowth< GUM_SCALAR >& from) :
47  u(from.u),
48  edge(from.edge), v(from.v), matches(from.matches),
51  GUM_CONS_CPY(EdgeGrowth);
52 
53  if (from.degree_list != 0) {
54  degree_list = new std::vector< NodeId >(*(from.degree_list));
55  }
56  }
57 
58  template < typename GUM_SCALAR >
60  GUM_DESTRUCTOR(EdgeGrowth);
61 
62  if (degree_list != 0) { delete degree_list; }
63  }
64 
65  template < typename GUM_SCALAR >
66  INLINE std::string EdgeGrowth< GUM_SCALAR >::toString() {
67  std::stringstream str;
68  str << u << "-" << edge << "-" << l_v << "-" << v;
69  return str.str();
70  }
71 
72  template < typename GUM_SCALAR >
75  NodeId id = iso_graph.addNode();
76  degree_list->push_back(id);
77 
78  for (const auto& elt : matches) {
79  if ((elt.second.first == u) || (elt.second.second == u)
80  || (elt.second.first == v) || (elt.second.second == v)) {
81  iso_graph.addEdge(elt.first, id);
82  }
83  }
84 
85  // The order between u and v is important ! DO NOT INVERSE IT !
86  matches.insert(id, std::make_pair(u, v));
87  }
88 
89  } /* namespace gspan */
90  } /* namespace prm */
91 } /* namespace gum */
Set< NodeId > max_indep_set
The max indep set of matches.
Definition: edgeGrowth.h:97
This class is used to define an edge growth of a pattern in this DFSTree.
Definition: edgeGrowth.h:60
LabelData * l_v
The LabelData over the node of this edge growth.
Definition: edgeGrowth.h:77
Inner class to handle data about labels in this interface graph.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:60
virtual void addEdge(const NodeId first, const NodeId second)
insert a new edge into the undirected graph
Definition: undiGraph_inl.h:32
STL namespace.
NodeProperty< std::pair< PRMInstance< GUM_SCALAR > *, PRMInstance< GUM_SCALAR > *> > matches
The mapping between the u and v for each match in the interface graph.
Definition: edgeGrowth.h:87
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
LabelData * edge
The LabelData over the edge of this edge growth.
Definition: edgeGrowth.h:75
std::vector< NodeId > * degree_list
Vector used for computation.
Definition: edgeGrowth.h:95
virtual NodeId addNode()
insert a new node and return its id
NodeId u
The id of the node from which we grow an edge.
Definition: edgeGrowth.h:73
NodeId v
If the growth is backward you must assigned the subscript of v, otherwise 0 is assigned (recall that ...
Definition: edgeGrowth.h:80
Headers of the DFSTree class.
std::string toString()
Return a string representation of this.
UndiGraph iso_graph
The iso graph for computing the maximum independent set of matches.
Definition: edgeGrowth.h:93
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(PRMInstance< GUM_SCALAR > *u, PRMInstance< GUM_SCALAR > *v)
Add the pair (u,v) as a match for the current growth.
EdgeGrowth(NodeId a_u, LabelData *an_edge, LabelData *a_l_v, NodeId a_v=0)
Constructor.