33 template <
typename GUM_SCALAR >
38 template <
typename GUM_SCALAR >
40 n(from.
n),
l(from.
l) {
44 template <
typename GUM_SCALAR >
49 template <
typename GUM_SCALAR >
52 return (
n == from.
n) && (
l == from.
l);
55 template <
typename GUM_SCALAR >
58 return (
n != from.
n) && (
l != from.
l);
63 template <
typename GUM_SCALAR >
68 template <
typename GUM_SCALAR >
70 u(from.
u),
v(from.
v),
l(from.
l) {
74 template <
typename GUM_SCALAR >
79 template <
typename GUM_SCALAR >
82 return (
u == from.
u) && (
l_u == from.
l_u) && (
v == from.
v)
83 && (
l_v == from.
l_v) && (
l == from.
l);
86 template <
typename GUM_SCALAR >
89 return (
u != from.
u) && (
l_u != from.
l_u) && (
v != from.
v)
90 && (
l_v != from.
l_v) && (
l != from.
l);
95 template <
typename GUM_SCALAR >
105 for (
auto iter = sys.
begin(); iter != sys.
end(); ++iter) {
107 node->
n = iter.val();
110 __idMap.insert(node->
n, iter.key());
117 for (
const auto& elt :
__nodes) {
120 for (
const auto chain : data->
n->type().slotChains()) {
121 for (
const auto inst : data->
n->getInstances(chain->id())) {
124 v = (u != data) ? data : __nodes[
__idMap[inst]];
141 template <
typename GUM_SCALAR >
153 template <
typename GUM_SCALAR >
158 for (
const auto& elt :
__nodes)
161 for (
const auto& elt :
__edges)
178 template <
typename GUM_SCALAR >
184 template <
typename GUM_SCALAR >
189 std::stringstream sBuff;
190 sBuff << node->
n->type().name();
193 for (
const auto chain : node->
n->type().slotChains()) {
194 if (chain->isMultiple()) {
195 sBuff <<
"-" << node->
n->getInstances(chain->id()).
size();
196 sBuff << chain->name();
197 size *= node->
n->getInstances(chain->id()).
size()
198 * chain->lastElt().type().variable().domainSize();
200 size *= chain->lastElt().type().variable().domainSize();
205 for (
const auto nn : node->
n->type().containerDag().nodes()) {
206 if (node->
n->type().isOutputNode(node->
n->type().get(nn))) {
208 sBuff <<
"-" << node->
n->getRefAttr(nn).size()
209 << node->
n->get(nn).name();
210 size *= node->
n->get(nn).type().variable().domainSize();
218 if (!label_map.
exists(sBuff.str())) {
223 label->
l = sBuff.str();
228 node->
l = label_map[sBuff.str()];
232 template <
typename GUM_SCALAR >
237 std::stringstream sBuff;
238 sBuff << edge->
u->type().name() <<
"-" << edge->
v->type().name();
241 for (
const auto chain : edge->
u->type().slotChains()) {
242 if (edge->
u->getInstances(chain->id()).exists(edge->
v)) {
243 sBuff <<
"-" << edge->
v->type().name() <<
"." 244 << chain->lastElt().name();
245 size *= chain->lastElt().type().variable().domainSize();
250 for (
const auto chain : edge->
v->type().slotChains())
251 if (edge->
v->getInstances(chain->id()).exists(edge->
u)) {
252 sBuff <<
"-" << edge->
u->type().name() <<
"." 253 << chain->lastElt().name();
254 size *= chain->lastElt().type().variable().domainSize();
258 if (!label_map.
exists(sBuff.str())) {
262 label->
l = sBuff.str();
268 edge->
l = label_map[sBuff.str()];
272 template <
typename GUM_SCALAR >
277 template <
typename GUM_SCALAR >
282 template <
typename GUM_SCALAR >
287 template <
typename GUM_SCALAR >
293 template <
typename GUM_SCALAR >
302 template <
typename GUM_SCALAR >
308 template <
typename GUM_SCALAR >
314 template <
typename GUM_SCALAR >
320 template <
typename GUM_SCALAR >
326 template <
typename GUM_SCALAR >
331 template <
typename GUM_SCALAR >
337 template <
typename GUM_SCALAR >
343 template <
typename GUM_SCALAR >
349 template <
typename GUM_SCALAR >
355 template <
typename GUM_SCALAR >
361 template <
typename GUM_SCALAR >
367 template <
typename GUM_SCALAR >
375 template <
typename GUM_SCALAR >
383 template <
typename GUM_SCALAR >
386 out << data.
n->name() <<
"(" << data.
l->l <<
")";
390 template <
typename GUM_SCALAR >
393 out << data.
u->name() <<
" -> " << data.
v->name() <<
"(" << data.
l->l
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
std::ostream & operator<<(std::ostream &out, const DFSCode &code)
Print code in out.
Inner class to handle data about labels in this interface graph.
Bijection< Idx, LabelData *> & labels()
Returns the bijection between LabelData and their string representation.
PRMInstance< GUM_SCALAR > * u
One of the two instance represented by this edge.
PRMInstance< GUM_SCALAR > * n
The instance represented by this node.
iterator begin()
Returns an iterator over the instances in this system.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
std::string l
The string version of this label.
virtual void addEdge(const NodeId first, const NodeId second)
insert a new edge into the undirected graph
NodeProperty< NodeData< GUM_SCALAR > *> __nodes
Data associated with a node in __graph.
HashTable< LabelData *, Set< NodeData< GUM_SCALAR > *> *> __nodeMap
Mapping between a LabelData and the set of NodeData<GUM_SCALAR> with that label.
UndiGraph __graph
The interface graph.
LabelData * l_u
The label data of u.
NodeData< GUM_SCALAR > & node(const PRMInstance< GUM_SCALAR > *i)
Returns data about a node.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
Inner class to handle data about edges in __graph.
Idx __counter
A counter used of assigning ids to labels.
PRMInstance< GUM_SCALAR > * v
The other instance represented by thus edge.
This class represent the interface graph of a given gum::prm::PRMSystem<GUM_SCALAR>.
gum is the global namespace for all aGrUM entities
~InterfaceGraph()
Destructor.
bool operator==(const EdgeData< GUM_SCALAR > &from) const
Equality operator.
EdgeProperty< EdgeData< GUM_SCALAR > *> __edges
Data associated with edges in __graph.
The class for generic Hash Tables.
LabelData * l
The labal data of this edge.
Representation of a setA Set is a structure that contains arbitrary elements.
const PRMSystem< GUM_SCALAR > * __sys
The gum::prm::PRMSystem<GUM_SCALAR> represented by this interface graph.
UndiGraph & graph()
Returns the graph of this interface graph.
bool operator==(const NodeData< GUM_SCALAR > &from) const
Equality operator.
HashTable< LabelData *, Set< EdgeData< GUM_SCALAR > *> *> __edgeMap
Mapping between a LabelData and the set of EdgeData<GUM_SCALAR> with that label.
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
InterfaceGraph(const PRMSystem< GUM_SCALAR > &sys)
Default constructor.
bool operator!=(const EdgeData< GUM_SCALAR > &from) const
Difference operator.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
LabelData * l
The label of this node.
Set of pairs of elements with fast search for both elements.
Set< EdgeData< GUM_SCALAR > *> & edges(const LabelData *l)
Returns the set of nodes labelled by l.
Inner class to handle data about nodes in __graph.
Idx id
An unique identifier for this label.
bool __erase_flag
For shallow copies.
LabelData * l_v
The label data of v.
NodeId id(const PRMInstance< GUM_SCALAR > &i) const
Returns the id of i in this interface graph.
The base class for all undirected edges.
HashTable< PRMInstance< GUM_SCALAR > *, NodeId > __idMap
Mapping between PRMInstance<GUM_SCALAR> dans their id in __graph.
LabelData * label(Idx id)
Returns a label given its id.
Bijection< Idx, LabelData *> * __labels
Bijection between labels and their ids.
Base class for undirected graphs.
void __label(NodeData< GUM_SCALAR > *node, HashTable< std::string, LabelData * > &label_map)
Compute the label of node and add it to __labels if it does not exists yet. Update node with the corr...
Size size(const LabelData *l) const
Returns the number of node or edges labelled by l.
Size Idx
Type for indexes.
Size tree_width
The size in terms of tree width of the given label.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
EdgeData< GUM_SCALAR > & edge(NodeId u, NodeId v)
Returns data about an edge.
Set< NodeData< GUM_SCALAR > *> & nodes(const LabelData *l)
Returns the set of nodes labelled by l.
Size NodeId
Type for node ids.
#define GUM_ERROR(type, msg)
InterfaceGraph & operator=(const InterfaceGraph &source)
Copy operator.
bool operator!=(const NodeData< GUM_SCALAR > &from) const
Difference operator.