aGrUM  0.13.2
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 44 of file classDependencyGraph.h.

Member Typedef Documentation

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 49 of file classDependencyGraph.h.

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 136 of file classDependencyGraph.h.

Constructor & Destructor Documentation

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 104 of file classDependencyGraph_tpl.h.

105  {
106  GUM_CONSTRUCTOR(ClassDependencyGraph);
107  __buildGraph(prm);
108  }
ClassDependencyGraph(const PRM< GUM_SCALAR > &prm)
Default constructor.
void __buildGraph(const PRM< GUM_SCALAR > &prm)
Build the class dependency graph.
template<typename GUM_SCALAR >
INLINE gum::prm::ClassDependencyGraph< GUM_SCALAR >::ClassDependencyGraph ( const ClassDependencyGraph< GUM_SCALAR > &  source)

Copy constructor.

Definition at line 111 of file classDependencyGraph_tpl.h.

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

112  :
113  __graph(source.__graph),
114  __modalitites(source.__modalitites), __elt_map(source.__elt_map) {
115  GUM_CONS_CPY(ClassDependencyGraph);
116 
117  for (const auto elt : source.__node_map) {
119  elt.first,
120  new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >(
121  *elt.second));
122  }
123  }
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
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.
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:

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

Destructor.

Definition at line 33 of file classDependencyGraph_tpl.h.

33  {
34  GUM_DESTRUCTOR(ClassDependencyGraph);
35 
36  for (const auto& elt : __node_map)
37  delete elt.second;
38 
39  for (const auto& elt : __elt_map)
40  delete elt.second;
41  }
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

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 73 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().

76  {
77  switch (c.get(node).elt_type()) {
79  const PRMSlotChain< GUM_SCALAR >& sc =
80  static_cast< const PRMSlotChain< GUM_SCALAR >& >(c.get(node));
81 
82  for (const auto chi : c.containerDag().children(node))
83  __graph.addArc((*(__node_map[&(sc.end())]))[&(
84  sc.end().get(sc.lastElt().safeName()))],
85  map[&(c.get(chi))]);
86 
87  break;
88  }
89 
92  for (const auto chi : c.containerDag().children(node))
93  __graph.addArc(map[&(c.get(node))], map[&(c.get(chi))]);
94 
95  break;
96  }
97 
98  default: { /* do nothing */ break;
99  }
100  }
101  }
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:40

+ Here is the call graph for this function:

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 150 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().

152  {
153  switch (elt.elt_type()) {
156  NodeId id = __graph.addNode();
157  __elt_map.insert(
159  __node_map[c]->insert(&elt, id);
160  __modalitites.insert(id, elt.type().variable().domainSize());
161  break;
162  }
163 
164  default: { /* do nothing */ break;
165  }
166  }
167  }
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
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.
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:

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 45 of file classDependencyGraph_tpl.h.

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

46  {
47  // First we add all nodes
48  for (const auto ci : prm.classes()) {
50  ci, new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >());
51 
52  for (const auto node : ci->containerDag().nodes())
53  __addNode(ci, ci->get(node));
54  }
55 
56  for (const auto ii : prm.interfaces()) {
58  ii, new HashTable< const PRMClassElement< GUM_SCALAR >*, NodeId >());
59 
60  for (const auto node : ii->containerDag().nodes()) {
61  __addNode(ii, ii->get(node));
62  }
63  }
64 
65  // Then we add the arcs
66  for (const auto cc : prm.classes())
67  for (const auto node : cc->containerDag().nodes())
68  __addArcs(*cc, node, *(__node_map[cc]));
69  }
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
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.

+ Here is the call graph for this function:

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 126 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().

126  {
127  return __graph;
128  }

+ Here is the caller graph for this function:

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 132 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().

132  {
133  return *(__elt_map[id]);
134  }
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:

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 137 of file classDependencyGraph_tpl.h.

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

139  {
140  return (*(__node_map[&c]))[&elt];
141  }
NodeMap __node_map
Map each Class to a HashTable mapping the Class&#39;s ClassElements to their assigned NodeId in __graph...
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 145 of file classDependencyGraph_tpl.h.

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

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

Member Data Documentation

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 130 of file classDependencyGraph.h.

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

template<typename GUM_SCALAR>
DAG gum::prm::ClassDependencyGraph< GUM_SCALAR >::__graph
private
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 123 of file classDependencyGraph.h.

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

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 141 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: