55 template <
typename GUM_SCALAR >
60 template <
typename GUM_SCALAR >
62 n(from.
n),
l(from.
l) {
66 template <
typename GUM_SCALAR >
71 template <
typename GUM_SCALAR >
73 return (
n == from.
n) && (
l == from.
l);
76 template <
typename GUM_SCALAR >
78 return (
n != from.
n) && (
l != from.
l);
83 template <
typename GUM_SCALAR >
88 template <
typename GUM_SCALAR >
90 u(from.
u),
v(from.
v),
l(from.
l) {
94 template <
typename GUM_SCALAR >
99 template <
typename GUM_SCALAR >
101 return (
u == from.
u) && (
l_u == from.
l_u) && (
v == from.
v) && (
l_v == from.
l_v)
105 template <
typename GUM_SCALAR >
107 return (
u != from.
u) && (
l_u != from.
l_u) && (
v != from.
v) && (
l_v != from.
l_v)
113 template <
typename GUM_SCALAR >
121 for (
auto iter = sys.
begin(); iter != sys.
end(); ++iter) {
123 node->n = iter.val();
125 _graph_.addNodeWithId(iter.key());
133 for (
const auto& elt:
_nodes_) {
136 for (
const auto chain: data->
n->type().slotChains()) {
137 for (
const auto inst: data->
n->getInstances(chain->id())) {
156 template <
typename GUM_SCALAR >
166 template <
typename GUM_SCALAR >
191 template <
typename GUM_SCALAR >
197 template <
typename GUM_SCALAR >
201 std::stringstream sBuff;
202 sBuff <<
node->n->type().name();
205 for (
const auto chain:
node->n->type().slotChains()) {
206 if (chain->isMultiple()) {
207 sBuff <<
"-" <<
node->n->getInstances(chain->id()).size();
208 sBuff << chain->name();
209 size *=
node->n->getInstances(chain->id()).size()
210 * chain->lastElt().type().variable().domainSize();
212 size *= chain->lastElt().type().variable().domainSize();
217 for (
const auto nn:
node->n->type().containerDag().nodes()) {
218 if (
node->n->type().isOutputNode(
node->n->type().get(nn))) {
220 sBuff <<
"-" <<
node->n->getRefAttr(nn).size() <<
node->n->get(nn).name();
221 size *=
node->n->get(nn).type().variable().domainSize();
229 if (!label_map.
exists(sBuff.str())) {
234 label->l = sBuff.str();
239 node->l = label_map[sBuff.str()];
243 template <
typename GUM_SCALAR >
247 std::stringstream sBuff;
248 sBuff <<
edge->u->type().name() <<
"-" <<
edge->v->type().name();
251 for (
const auto chain:
edge->u->type().slotChains()) {
252 if (
edge->u->getInstances(chain->id()).exists(
edge->v)) {
253 sBuff <<
"-" <<
edge->v->type().name() <<
"." << chain->lastElt().name();
254 size *= chain->lastElt().type().variable().domainSize();
259 for (
const auto chain:
edge->v->type().slotChains())
260 if (
edge->v->getInstances(chain->id()).exists(
edge->u)) {
261 sBuff <<
"-" <<
edge->u->type().name() <<
"." << chain->lastElt().name();
262 size *= chain->lastElt().type().variable().domainSize();
266 if (!label_map.
exists(sBuff.str())) {
270 label->l = sBuff.str();
276 edge->l = label_map[sBuff.str()];
280 template <
typename GUM_SCALAR >
285 template <
typename GUM_SCALAR >
290 template <
typename GUM_SCALAR >
295 template <
typename GUM_SCALAR >
300 template <
typename GUM_SCALAR >
307 template <
typename GUM_SCALAR >
313 template <
typename GUM_SCALAR >
319 template <
typename GUM_SCALAR >
325 template <
typename GUM_SCALAR >
331 template <
typename GUM_SCALAR >
336 template <
typename GUM_SCALAR >
341 template <
typename GUM_SCALAR >
346 template <
typename GUM_SCALAR >
352 template <
typename GUM_SCALAR >
358 template <
typename GUM_SCALAR >
363 template <
typename GUM_SCALAR >
368 template <
typename GUM_SCALAR >
375 template <
typename GUM_SCALAR >
383 template <
typename GUM_SCALAR >
385 out << data.
n->name() <<
"(" << data.
l->
l <<
")";
389 template <
typename GUM_SCALAR >
391 out << data.
u->name() <<
" -> " << data.
v->name() <<
"(" << data.
l->
l <<
")";
Set of pairs of elements with fast search for both elements.
The base class for all undirected edges.
Exception : fatal (unknown ?) error.
The class for generic Hash Tables.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
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.
Base class for undirected graphs.
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
iterator begin()
Returns an iterator over the instances in this system.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.
Inner class to handle data about edges in graph.
bool operator==(const EdgeData< GUM_SCALAR > &from) const
Equality operator.
PRMInstance< GUM_SCALAR > * v
The other instance represented by thus edge.
PRMInstance< GUM_SCALAR > * u
One of the two instance represented by this edge.
LabelData * l_u
The label data of u.
LabelData * l
The labal data of this edge.
bool operator!=(const EdgeData< GUM_SCALAR > &from) const
Difference operator.
LabelData * l_v
The label data of v.
This class represent the interface graph of a given gum::prm::PRMSystem<GUM_SCALAR>.
const PRMSystem< GUM_SCALAR > * _sys_
The gum::prm::PRMSystem<GUM_SCALAR> represented by this interface graph.
NodeProperty< NodeData< GUM_SCALAR > * > _nodes_
Data associated with a node in graph.
Size size(const LabelData *l) const
Returns the number of node or edges labelled by l.
Bijection< Idx, LabelData * > & labels()
Returns the bijection between LabelData and their string representation.
UndiGraph _graph_
The interface graph.
InterfaceGraph & operator=(const InterfaceGraph &source)
Copy operator.
Idx _counter_
A counter used of assigning ids to labels.
InterfaceGraph(const PRMSystem< GUM_SCALAR > &sys)
Default constructor.
NodeId id(const PRMInstance< GUM_SCALAR > &i) const
Returns the id of i in this interface graph.
HashTable< LabelData *, Set< NodeData< GUM_SCALAR > * > * > _nodeMap_
Mapping between a LabelData and the set of NodeData<GUM_SCALAR> with that label.
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.
EdgeProperty< EdgeData< GUM_SCALAR > * > _edges_
Data associated with edges in graph.
~InterfaceGraph()
Destructor.
bool _erase_flag_
For shallow copies.
HashTable< LabelData *, Set< EdgeData< GUM_SCALAR > * > * > _edgeMap_
Mapping between a LabelData and the set of EdgeData<GUM_SCALAR> with that label.
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 correc...
UndiGraph & graph()
Returns the graph of this interface graph.
NodeData< GUM_SCALAR > & node(const PRMInstance< GUM_SCALAR > *i)
Returns data about a node.
LabelData * label(Idx id)
Returns a label given its id.
Bijection< Idx, LabelData * > * _labels_
Bijection between labels and their ids.
Set< EdgeData< GUM_SCALAR > * > & edges(const LabelData *l)
Returns the set of nodes labelled by l.
HashTable< PRMInstance< GUM_SCALAR > *, NodeId > _idMap_
Mapping between PRMInstance<GUM_SCALAR> dans their id in graph.
Inner class to handle data about nodes in graph.
PRMInstance< GUM_SCALAR > * n
The instance represented by this node.
bool operator==(const NodeData< GUM_SCALAR > &from) const
Equality operator.
bool operator!=(const NodeData< GUM_SCALAR > &from) const
Difference operator.
LabelData * l
The label of this node.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
std::ostream & operator<<(std::ostream &out, const DFSCode &code)
Print code in out.
namespace for all probabilistic relational models entities
gum is the global namespace for all aGrUM entities
Inner class to handle data about labels in this interface graph.
std::string l
The string version of this label.