aGrUM  0.16.0
gum::prm::ClassDependencyGraph< GUM_SCALAR > Class Template Reference

This class represent the dependencies of all classes in a PRM<GUM_SCALAR>. More...

#include <agrum/PRM/classDependencyGraph.h>

+ Collaboration diagram for gum::prm::ClassDependencyGraph< GUM_SCALAR >:

Public Member Functions

Constructors and Destructor.
 ClassDependencyGraph (const PRM< GUM_SCALAR > &prm)
 Default constructor. More...
 
 ClassDependencyGraph (const ClassDependencyGraph< GUM_SCALAR > &source)
 Copy constructor. More...
 
 ~ClassDependencyGraph ()
 Destructor. More...
 
Getters & setters.
const DAGdag () const
 Returns a constant reference over the graph of the DAG representing the ClassDependencyGraph<GUM_SCALAR>. More...
 
const EltPairget (NodeId id) const
 Returns a constant reference over the element assiociated with the node id in the ClassDependencyGraph<GUM_SCALAR>. More...
 
NodeId get (const PRMClassElementContainer< GUM_SCALAR > &c, const PRMClassElement< GUM_SCALAR > &elt) const
 Returns the NodeId assign to the given PRMClassElement<GUM_SCALAR> of a given Class. Is is necessary to give both Class and PRMClassElement<GUM_SCALAR> because inherited PRMClassElement<GUM_SCALAR> are shared in the inheritance hierarchy. More...
 
const NodeProperty< Size > & modalities () const
 Returns a mapping between the ClassDependencyGraph<GUM_SCALAR>'s nodes and their modalities. More...
 

Public Types

typedef std::pair< const PRMClassElementContainer< GUM_SCALAR > *, const PRMClassElement< GUM_SCALAR > *> EltPair
 Association between a class element and it's holding class. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::ClassDependencyGraph< GUM_SCALAR >

This class represent the dependencies of all classes in a PRM<GUM_SCALAR>.

A Class Dependency Graph does listen to changes in it's PRM<GUM_SCALAR>.

Definition at line 47 of file classDependencyGraph.h.

Member Typedef Documentation

◆ EltPair

template<typename GUM_SCALAR>
typedef std::pair< const PRMClassElementContainer< GUM_SCALAR >*, const PRMClassElement< GUM_SCALAR >* > gum::prm::ClassDependencyGraph< GUM_SCALAR >::EltPair

Association between a class element and it's holding class.

Definition at line 52 of file classDependencyGraph.h.

◆ NodeMap

template<typename GUM_SCALAR>
typedef HashTable< const PRMClassElementContainer< GUM_SCALAR >*, HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >* > gum::prm::ClassDependencyGraph< GUM_SCALAR >::NodeMap
private

Code shortcut.

Definition at line 139 of file classDependencyGraph.h.

Constructor & Destructor Documentation

◆ ClassDependencyGraph() [1/2]

template<typename GUM_SCALAR >
INLINE gum::prm::ClassDependencyGraph< GUM_SCALAR >::ClassDependencyGraph ( const PRM< GUM_SCALAR > &  prm)

Default constructor.

Parameters
prmThe PRM<GUM_SCALAR> for which this ClassDependencyGraph<GUM_SCALAR> is constructed.

Definition at line 107 of file classDependencyGraph_tpl.h.

108  {
109  GUM_CONSTRUCTOR(ClassDependencyGraph);
110  __buildGraph(prm);
111  }
ClassDependencyGraph(const PRM< GUM_SCALAR > &prm)
Default constructor.
void __buildGraph(const PRM< GUM_SCALAR > &prm)
Build the class dependency graph.

◆ ClassDependencyGraph() [2/2]

template<typename GUM_SCALAR >
INLINE gum::prm::ClassDependencyGraph< GUM_SCALAR >::ClassDependencyGraph ( const ClassDependencyGraph< GUM_SCALAR > &  source)

Copy constructor.

Definition at line 114 of file classDependencyGraph_tpl.h.

References gum::prm::ClassDependencyGraph< GUM_SCALAR >::__node_map, and gum::HashTable< Key, Val, Alloc >::insert().

115  :
116  __graph(source.__graph),
117  __modalitites(source.__modalitites), __elt_map(source.__elt_map) {
118  GUM_CONS_CPY(ClassDependencyGraph);
119 
120  for (const auto elt : source.__node_map) {
122  elt.first,
123  new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >(
124  *elt.second));
125  }
126  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...
ClassDependencyGraph(const PRM< GUM_SCALAR > &prm)
Default constructor.
NodeProperty< Size > __modalitites
The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a...
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
NodeProperty< EltPair *> __elt_map
Mapping between the nodes in __graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.
+ Here is the call graph for this function:

◆ ~ClassDependencyGraph()

template<typename GUM_SCALAR >
gum::prm::ClassDependencyGraph< GUM_SCALAR >::~ClassDependencyGraph ( )

Destructor.

Definition at line 36 of file classDependencyGraph_tpl.h.

36  {
37  GUM_DESTRUCTOR(ClassDependencyGraph);
38 
39  for (const auto& elt : __node_map)
40  delete elt.second;
41 
42  for (const auto& elt : __elt_map)
43  delete elt.second;
44  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...
ClassDependencyGraph(const PRM< GUM_SCALAR > &prm)
Default constructor.
NodeProperty< EltPair *> __elt_map
Mapping between the nodes in __graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.

Member Function Documentation

◆ __addArcs()

template<typename GUM_SCALAR >
void gum::prm::ClassDependencyGraph< GUM_SCALAR >::__addArcs ( const PRMClassElementContainer< GUM_SCALAR > &  c,
NodeId  node,
HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > &  map 
)
private

Add arcs in __graph.

Definition at line 76 of file classDependencyGraph_tpl.h.

References gum::prm::PRMClassElementContainer< GUM_SCALAR >::containerDag(), gum::prm::PRMSlotChain< GUM_SCALAR >::end(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), and gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt().

79  {
80  switch (c.get(node).elt_type()) {
82  const PRMSlotChain< GUM_SCALAR >& sc =
83  static_cast< const PRMSlotChain< GUM_SCALAR >& >(c.get(node));
84 
85  for (const auto chi : c.containerDag().children(node))
86  __graph.addArc((*(__node_map[&(sc.end())]))[&(
87  sc.end().get(sc.lastElt().safeName()))],
88  map[&(c.get(chi))]);
89 
90  break;
91  }
92 
95  for (const auto chi : c.containerDag().children(node))
96  __graph.addArc(map[&(c.get(node))], map[&(c.get(chi))]);
97 
98  break;
99  }
100 
101  default: { /* do nothing */ break;
102  }
103  }
104  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:43
+ Here is the call graph for this function:

◆ __addNode()

template<typename GUM_SCALAR >
INLINE void gum::prm::ClassDependencyGraph< GUM_SCALAR >::__addNode ( const PRMClassElementContainer< GUM_SCALAR > *  c,
const PRMClassElement< GUM_SCALAR > &  elt 
)
private

Add nodes in __graph while updating consequently all the mappings.

Definition at line 153 of file classDependencyGraph_tpl.h.

References gum::prm::ClassDependencyGraph< GUM_SCALAR >::__elt_map, gum::prm::ClassDependencyGraph< GUM_SCALAR >::__graph, gum::prm::ClassDependencyGraph< GUM_SCALAR >::__modalitites, gum::prm::ClassDependencyGraph< GUM_SCALAR >::__node_map, gum::NodeGraphPart::addNode(), gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::HashTable< Key, Val, Alloc >::insert(), and gum::prm::PRMClassElement< GUM_SCALAR >::type().

155  {
156  switch (elt.elt_type()) {
159  NodeId id = __graph.addNode();
160  __elt_map.insert(
162  __node_map[c]->insert(&elt, id);
163  __modalitites.insert(id, elt.type().variable().domainSize());
164  break;
165  }
166 
167  default: { /* do nothing */ break;
168  }
169  }
170  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...
virtual NodeId addNode()
insert a new node and return its id
std::pair< const PRMClassElementContainer< GUM_SCALAR > *, const PRMClassElement< GUM_SCALAR > *> EltPair
Association between a class element and it&#39;s holding class.
NodeProperty< Size > __modalitites
The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a...
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
NodeProperty< EltPair *> __elt_map
Mapping between the nodes in __graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.
+ Here is the call graph for this function:

◆ __buildGraph()

template<typename GUM_SCALAR >
void gum::prm::ClassDependencyGraph< GUM_SCALAR >::__buildGraph ( const PRM< GUM_SCALAR > &  prm)
private

Build the class dependency graph.

Definition at line 48 of file classDependencyGraph_tpl.h.

References gum::prm::PRM< GUM_SCALAR >::classes(), and gum::prm::PRM< GUM_SCALAR >::interfaces().

49  {
50  // First we add all nodes
51  for (const auto ci : prm.classes()) {
53  ci, new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >());
54 
55  for (const auto node : ci->containerDag().nodes())
56  __addNode(ci, ci->get(node));
57  }
58 
59  for (const auto ii : prm.interfaces()) {
61  ii, new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >());
62 
63  for (const auto node : ii->containerDag().nodes()) {
64  __addNode(ii, ii->get(node));
65  }
66  }
67 
68  // Then we add the arcs
69  for (const auto cc : prm.classes())
70  for (const auto node : cc->containerDag().nodes())
71  __addArcs(*cc, node, *(__node_map[cc]));
72  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...
void __addNode(const PRMClassElementContainer< GUM_SCALAR > *c, const PRMClassElement< GUM_SCALAR > &elt)
Add nodes in __graph while updating consequently all the mappings.
void __addArcs(const PRMClassElementContainer< GUM_SCALAR > &c, NodeId node, HashTable< const PRMClassElement< GUM_SCALAR > *, NodeId > &map)
Add arcs in __graph.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ Here is the call graph for this function:

◆ dag()

template<typename GUM_SCALAR >
INLINE const DAG & gum::prm::ClassDependencyGraph< GUM_SCALAR >::dag ( ) const

Returns a constant reference over the graph of the DAG representing the ClassDependencyGraph<GUM_SCALAR>.

Definition at line 129 of file classDependencyGraph_tpl.h.

References gum::prm::ClassDependencyGraph< GUM_SCALAR >::__graph.

Referenced by gum::prm::SVED< GUM_SCALAR >::__initElimOrder(), and gum::prm::SVE< GUM_SCALAR >::__initElimOrder().

129  {
130  return __graph;
131  }
+ Here is the caller graph for this function:

◆ get() [1/2]

template<typename GUM_SCALAR >
INLINE const ClassDependencyGraph< GUM_SCALAR >::EltPair & gum::prm::ClassDependencyGraph< GUM_SCALAR >::get ( NodeId  id) const

Returns a constant reference over the element assiociated with the node id in the ClassDependencyGraph<GUM_SCALAR>.

Exceptions
NotFoundRaised if no nodes matches id.

Definition at line 135 of file classDependencyGraph_tpl.h.

References gum::prm::ClassDependencyGraph< GUM_SCALAR >::__elt_map.

Referenced by gum::prm::SVED< GUM_SCALAR >::__initElimOrder(), and gum::prm::SVE< GUM_SCALAR >::__initElimOrder().

135  {
136  return *(__elt_map[id]);
137  }
NodeProperty< EltPair *> __elt_map
Mapping between the nodes in __graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.
+ Here is the caller graph for this function:

◆ get() [2/2]

template<typename GUM_SCALAR >
INLINE NodeId gum::prm::ClassDependencyGraph< GUM_SCALAR >::get ( const PRMClassElementContainer< GUM_SCALAR > &  c,
const PRMClassElement< GUM_SCALAR > &  elt 
) const

Returns the NodeId assign to the given PRMClassElement<GUM_SCALAR> of a given Class. Is is necessary to give both Class and PRMClassElement<GUM_SCALAR> because inherited PRMClassElement<GUM_SCALAR> are shared in the inheritance hierarchy.

Definition at line 140 of file classDependencyGraph_tpl.h.

References gum::prm::ClassDependencyGraph< GUM_SCALAR >::__node_map.

142  {
143  return (*(__node_map[&c]))[&elt];
144  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...

◆ modalities()

template<typename GUM_SCALAR >
INLINE const NodeProperty< Size > & gum::prm::ClassDependencyGraph< GUM_SCALAR >::modalities ( ) const

Returns a mapping between the ClassDependencyGraph<GUM_SCALAR>'s nodes and their modalities.

Definition at line 148 of file classDependencyGraph_tpl.h.

References gum::prm::ClassDependencyGraph< GUM_SCALAR >::__modalitites.

148  {
149  return __modalitites;
150  }
NodeProperty< Size > __modalitites
The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a...

Member Data Documentation

◆ __elt_map

template<typename GUM_SCALAR>
NodeProperty< EltPair* > gum::prm::ClassDependencyGraph< GUM_SCALAR >::__elt_map
private

Mapping between the nodes in __graph with the PRMClassElement<GUM_SCALAR> in the PRM<GUM_SCALAR>.

Definition at line 133 of file classDependencyGraph.h.

Referenced by gum::prm::ClassDependencyGraph< GUM_SCALAR >::__addNode(), and gum::prm::ClassDependencyGraph< GUM_SCALAR >::get().

◆ __graph

template<typename GUM_SCALAR>
DAG gum::prm::ClassDependencyGraph< GUM_SCALAR >::__graph
private

◆ __modalitites

template<typename GUM_SCALAR>
NodeProperty< Size > gum::prm::ClassDependencyGraph< GUM_SCALAR >::__modalitites
private

The modalities map for each node in the ClassDependencyGraph<GUM_SCALAR>. This is useful when using a Triangulation class over a ClassDependencyGraph<GUM_SCALAR>.

Definition at line 126 of file classDependencyGraph.h.

Referenced by gum::prm::ClassDependencyGraph< GUM_SCALAR >::__addNode(), and gum::prm::ClassDependencyGraph< GUM_SCALAR >::modalities().

◆ __node_map

template<typename GUM_SCALAR>
NodeMap gum::prm::ClassDependencyGraph< GUM_SCALAR >::__node_map
private

Map each Class to a HashTable mapping the Class's ClassElements to their assigned NodeId in __graph.

Definition at line 144 of file classDependencyGraph.h.

Referenced by gum::prm::ClassDependencyGraph< GUM_SCALAR >::__addNode(), gum::prm::ClassDependencyGraph< GUM_SCALAR >::ClassDependencyGraph(), and gum::prm::ClassDependencyGraph< GUM_SCALAR >::get().


The documentation for this class was generated from the following files: