Tulip  5.1.0
Large graphs analysis and drawing
AbstractProperty.cxx
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 #include <cstdlib>
20 #include <tulip/GraphIterator.h>
21 
22 template <class Tnode, class Tedge, class Tprop>
24  Tprop::graph = sg;
25  Tprop::name = n;
26  nodeDefaultValue = Tnode::defaultValue();
27  edgeDefaultValue = Tedge::defaultValue();
28  nodeProperties.setAll(Tnode::defaultValue());
29  edgeProperties.setAll(Tedge::defaultValue());
30  Tprop::metaValueCalculator = NULL;
31 }
32 //=============================================================
33 template <class Tnode, class Tedge, class Tprop>
34 inline typename Tnode::RealType tlp::AbstractProperty<Tnode,Tedge,Tprop>::getNodeDefaultValue() const {
35  return nodeDefaultValue;
36 }
37 //=============================================================
38 template <class Tnode, class Tedge, class Tprop>
39 inline typename Tedge::RealType tlp::AbstractProperty<Tnode,Tedge,Tprop>::getEdgeDefaultValue() const {
40  return edgeDefaultValue;
41 }
42 //=============================================================
43 template <class Tnode, class Tedge, class Tprop>
44 inline typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue tlp::AbstractProperty<Tnode,Tedge,Tprop>::getNodeValue(const tlp::node n ) const {
45  assert(n.isValid());
46  return nodeProperties.get(n.id);
47 }
48 //=============================================================
49 template <class Tnode, class Tedge, class Tprop>
50 inline typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue tlp::AbstractProperty<Tnode,Tedge,Tprop>::getEdgeValue(const tlp::edge e) const {
51  assert(e.isValid());
52  return edgeProperties.get(e.id);
53 }
54 //=================================================================================
55 template <class Tnode, class Tedge, class Tprop>
56 tlp::Iterator<tlp::node>* tlp::AbstractProperty<Tnode,Tedge,Tprop>::getNodesEqualTo(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue val, const Graph *sg) const {
57  if (sg == NULL) sg = this->graph;
58 
59  tlp::Iterator<unsigned int> *it = NULL;
60 
61  if (sg == this->graph)
62  it = nodeProperties.findAll(val);
63 
64  if (it == NULL)
65  return new tlp::SGraphNodeIterator<typename Tnode::RealType>(sg, nodeProperties, val);
66 
67  return (new tlp::UINTIterator<node>(it));
68 }
69 //=================================================================================
70 template <class Tnode, class Tedge, class Tprop>
71 tlp::Iterator<tlp::edge>* tlp::AbstractProperty<Tnode,Tedge,Tprop>::getEdgesEqualTo(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue val, const Graph *sg) const {
72  if (sg == NULL) sg = this->graph;
73 
74  tlp::Iterator<unsigned int> *it = NULL;
75 
76  if (sg == this->graph)
77  it = edgeProperties.findAll(val);
78 
79  if (it == NULL)
80  return new tlp::SGraphEdgeIterator<typename Tedge::RealType>(sg, edgeProperties, val);
81 
82  return (new tlp::UINTIterator<edge>(it));
83 }
84 //=============================================================
85 template <class Tnode, class Tedge, class Tprop>
86 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setNodeValue(const tlp::node n, typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v) {
87  assert(n.isValid());
88  Tprop::notifyBeforeSetNodeValue(n);
89  nodeProperties.set(n.id,v);
90  Tprop::notifyAfterSetNodeValue(n);
91 }
92 //=============================================================
93 template <class Tnode, class Tedge, class Tprop>
94 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setEdgeValue(const tlp::edge e, typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
95  assert(e.isValid());
96  Tprop::notifyBeforeSetEdgeValue(e);
97  edgeProperties.set(e.id,v);
98  Tprop::notifyAfterSetEdgeValue(e);
99 }
100 //=============================================================
101 template <class Tnode, class Tedge, class Tprop>
102 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setAllNodeValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v) {
103  Tprop::notifyBeforeSetAllNodeValue();
104  nodeDefaultValue = v;
105  nodeProperties.setAll(v);
106  Tprop::notifyAfterSetAllNodeValue();
107 }
108 //=============================================================
109 template <class Tnode, class Tedge, class Tprop>
110 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setNodeDefaultValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v) {
111  if (nodeDefaultValue == v) {
112  return;
113  }
114 
115  // backup old default value
116  typename Tnode::RealType oldDefaultValue = nodeDefaultValue;
117  // we need to get the list of nodes whose value equals the current default one first
118  std::vector<tlp::node> nodesOldDefaultToUpdate;
119  std::vector<tlp::node> nodesDefaultToUpdate;
120  const std::vector<tlp::node> &nodes = this->getGraph()->nodes();
121 
122  for (size_t i = 0 ; i < nodes.size() ; ++i) {
123  const typename Tnode::RealType &val = this->getNodeValue(nodes[i]);
124 
125  if (val == oldDefaultValue) {
126  nodesOldDefaultToUpdate.push_back(nodes[i]);
127  }
128  else if (val == v) {
129  nodesDefaultToUpdate.push_back(nodes[i]);
130  }
131  }
132 
133  // set new default value that will be associated to future added nodes
134  nodeDefaultValue = v;
135  nodeProperties.setDefault(v);
136 
137  // reset the backup nodes to the old default value as there is a new one in the
138  // underlying MutableContainer
139  for (size_t i = 0 ; i < nodesOldDefaultToUpdate.size() ; ++i) {
140  nodeProperties.set(nodesOldDefaultToUpdate[i].id, oldDefaultValue);
141  }
142 
143  // reset the backup nodes to their current value in order
144  // to synchronize the underlying MutableContainer state
145  for (size_t i = 0 ; i < nodesDefaultToUpdate.size() ; ++i) {
146  nodeProperties.set(nodesDefaultToUpdate[i].id, v);
147  }
148 }
149 //=============================================================
150 template <class Tnode, class Tedge, class Tprop>
151 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setAllNodeValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *graph) {
152  setValueToGraphNodes(v, graph);
153 }
154 //=============================================================
155 template <class Tnode, class Tedge, class Tprop>
156 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setValueToGraphNodes(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *graph) {
157  if (this->getGraph() == graph || this->getGraph()->isDescendantGraph(graph)) {
158  const std::vector<node>& nodes = graph->nodes();
159  unsigned int nbNodes = nodes.size();
160 
161  for(unsigned int i = 0; i < nbNodes; ++i) {
162  setNodeValue(nodes[i], v);
163  }
164  }
165 }
166 //=============================================================
167 template <class Tnode, class Tedge, class Tprop>
168 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setEdgeDefaultValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
169  if (edgeDefaultValue == v) {
170  return;
171  }
172 
173  // backup old default value
174  typename Tedge::RealType oldDefaultValue = edgeDefaultValue;
175  // backup list of edges whose value equals the current default one
176  std::vector<tlp::edge> edgesOldDefaultToUpdate;
177  // backup list of edges whose value equals the new default one
178  std::vector<tlp::edge> edgesDefaultToUpdate;
179  const std::vector<tlp::edge> &edges = this->getGraph()->edges();
180 
181  for (size_t i = 0 ; i < edges.size() ; ++i) {
182  const typename Tedge::RealType &val = this->getEdgeValue(edges[i]);
183 
184  if (val == oldDefaultValue) {
185  edgesOldDefaultToUpdate.push_back(edges[i]);
186  }
187  else if (val == v) {
188  edgesDefaultToUpdate.push_back(edges[i]);
189  }
190  }
191 
192  // set new default value that will be associated to future added edges
193  edgeDefaultValue = v;
194  edgeProperties.setDefault(v);
195 
196  // reset the backup edges to the old default value as there is a new one in the
197  // underlying MutableContainer
198  for (size_t i = 0 ; i < edgesOldDefaultToUpdate.size() ; ++i) {
199  edgeProperties.set(edgesOldDefaultToUpdate[i].id, oldDefaultValue);
200  }
201 
202  // reset the backup edges to their current value in order
203  // to synchronize the underlying MutableContainer state
204  for (size_t i = 0 ; i < edgesDefaultToUpdate.size() ; ++i) {
205  edgeProperties.set(edgesDefaultToUpdate[i].id, v);
206  }
207 }
208 //============================================================
209 template <class Tnode, class Tedge, class Tprop>
210 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
211  Tprop::notifyBeforeSetAllEdgeValue();
212  edgeDefaultValue = v;
213  edgeProperties.setAll(v);
214  Tprop::notifyAfterSetAllEdgeValue();
215 }
216 //============================================================
217 template <class Tnode, class Tedge, class Tprop>
218 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *graph) {
219  setValueToGraphEdges(v, graph);
220 }
221 //============================================================
222 template <class Tnode, class Tedge, class Tprop>
223 void tlp::AbstractProperty<Tnode,Tedge,Tprop>::setValueToGraphEdges(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *graph) {
224  if (this->getGraph() == graph || this->getGraph()->isDescendantGraph(graph)) {
225  const std::vector<edge>& edges = graph->edges();
226  unsigned int nbEdges = edges.size();
227 
228  for(unsigned int i = 0; i < nbEdges; ++i) {
229  setEdgeValue(edges[i], v);
230  }
231  }
232 }
233 //============================================================
234 template <class Tnode, class Tedge, class Tprop>
235 int tlp::AbstractProperty<Tnode,Tedge,Tprop>::compare(const node n1,const node n2)const {
236  const typename Tnode::RealType& n1Value = getNodeValue(n1);
237  const typename Tnode::RealType& n2Value = getNodeValue(n2);
238  return (n1Value < n2Value) ? -1 : ((n1Value == n2Value) ? 0 : 1);
239 }
240 //============================================================
241 template <class Tnode, class Tedge, class Tprop>
242 int tlp::AbstractProperty<Tnode,Tedge,Tprop>::compare(const edge e1,const edge e2)const {
243  const typename Tedge::RealType& e1Value = getEdgeValue(e1);
244  const typename Tedge::RealType& e2Value = getEdgeValue(e2);
245  return (e1Value < e2Value) ? -1 : ((e1Value == e2Value) ? 0 : 1);
246 }
247 //============================================================
248 // define template iterator class to iterate over graph elts
249 // belonging to a given graph instance
250 // used by the two methods below
251 ///@cond DOXYGEN_HIDDEN
252 template <typename ELT_TYPE>
253 class GraphEltIterator :public tlp::Iterator<ELT_TYPE> {
254 public:
255  ELT_TYPE next() {
256  ELT_TYPE tmp = curElt;
257 
258  if ((_hasnext = it->hasNext())) {
259  curElt = it->next();
260 
261  while (!(_hasnext = (!graph || graph->isElement(curElt)))) {
262  if (!it->hasNext()) break;
263 
264  curElt=it->next();
265  }
266  }
267 
268  return tmp;
269  }
270  GraphEltIterator(const tlp::Graph* g, tlp::Iterator<ELT_TYPE>* itN)
271  :it(itN), graph(g), curElt(ELT_TYPE()), _hasnext(false) {
272  next();
273  }
274 
275  bool hasNext() {
276  return (_hasnext);
277  }
278  ~GraphEltIterator() {
279  delete it;
280  }
281 
282 private:
283  tlp::Iterator<ELT_TYPE> *it;
284  const tlp::Graph* graph;
285  ELT_TYPE curElt;
286  bool _hasnext;
287 };
288 ///@endcond
289 
290 //============================================================
291 template <class Tnode, class Tedge, class Tprop>
292 tlp::Iterator<tlp::node>* tlp::AbstractProperty<Tnode,Tedge,Tprop>::getNonDefaultValuatedNodes(const Graph* g) const {
293  tlp::Iterator<tlp::node> *it =
294  new tlp::UINTIterator<tlp::node>(nodeProperties.findAll(nodeDefaultValue, false));
295 
296  if (Tprop::name.empty())
297  // we always need to check that nodes belong to graph
298  // for non registered properties, because deleted nodes are not erased
299  // from them
300  return new GraphEltIterator<tlp::node>(g != NULL ? g : Tprop::graph, it);
301 
302  return ((g == NULL) || (g == Tprop::graph)) ? it : new GraphEltIterator<tlp::node>(g, it);
303 }
304 //============================================================
305 template <class Tnode, class Tedge, class Tprop>
307  if (g == NULL) {
308  return nodeProperties.numberOfNonDefaultValues();
309  }
310  else {
311  unsigned int ret = 0;
312  node n;
313  forEach(n, getNonDefaultValuatedNodes(g)) {
314  ++ret;
315  }
316  return ret;
317  }
318 }
319 //============================================================
320 template <class Tnode, class Tedge, class Tprop>
322  return Tnode::valueSize();
323 }
324 //============================================================
325 template <class Tnode, class Tedge, class Tprop>
327  Tnode::writeb(oss, nodeDefaultValue);
328 }
329 //============================================================
330 template <class Tnode, class Tedge, class Tprop>
332  node n) const {
333  assert(n.isValid());
334  Tnode::writeb(oss, nodeProperties.get(n.id));
335 }
336 //============================================================
337 template <class Tnode, class Tedge, class Tprop>
339  if (Tnode::readb(iss, nodeDefaultValue)) {
340  nodeProperties.setAll(nodeDefaultValue);
341  return true;
342  }
343 
344  return false;
345 }
346 //============================================================
347 template <class Tnode, class Tedge, class Tprop>
349  node n) {
350  typename Tnode::RealType val;
351 
352  if (Tnode::readb(iss, val)) {
353  nodeProperties.set(n.id, val);
354  return true;
355  }
356 
357  return false;
358 }
359 //============================================================
360 template <class Tnode, class Tedge, class Tprop>
361 tlp::Iterator<tlp::edge>* tlp::AbstractProperty<Tnode,Tedge,Tprop>::getNonDefaultValuatedEdges(const Graph* g) const {
362  tlp::Iterator<tlp::edge>* it =
363  new tlp::UINTIterator<tlp::edge>(edgeProperties.findAll(edgeDefaultValue, false));
364 
365  if (Tprop::name.empty())
366  // we always need to check that edges belong to graph
367  // for non registered properties, because deleted edges are not erased
368  // from them
369  return new GraphEltIterator<tlp::edge>(g != NULL ? g : Tprop::graph, it);
370 
371  return ((g == NULL) || (g == Tprop::graph)) ? it : new GraphEltIterator<tlp::edge>(g, it);
372 }
373 //============================================================
374 template <class Tnode, class Tedge, class Tprop>
376  if (g == NULL) {
377  return edgeProperties.numberOfNonDefaultValues();
378  }
379  else {
380  unsigned int ret = 0;
381  edge e;
382  forEach(e, getNonDefaultValuatedEdges(g)) {
383  ++ret;
384  }
385  return ret;
386  }
387 }
388 //============================================================
389 template <class Tnode, class Tedge, class Tprop>
391  return Tedge::valueSize();
392 }
393 //============================================================
394 template <class Tnode, class Tedge, class Tprop>
396  Tedge::writeb(oss, edgeDefaultValue);
397 }
398 //============================================================
399 template <class Tnode, class Tedge, class Tprop>
401  edge e) const {
402  assert(e.isValid());
403  Tedge::writeb(oss, edgeProperties.get(e.id));
404 }
405 //============================================================
406 template <class Tnode, class Tedge, class Tprop>
408  if (Tedge::readb(iss, edgeDefaultValue)) {
409  edgeProperties.setAll(edgeDefaultValue);
410  return true;
411  }
412 
413  return false;
414 }
415 //============================================================
416 template <class Tnode, class Tedge, class Tprop>
418  edge e) {
419  typename Tedge::RealType val;
420 
421  if (Tedge::readb(iss, val)) {
422  edgeProperties.set(e.id, val);
423  return true;
424  }
425 
426  return false;
427 }
428 //============================================================
429 template <typename vectType, typename eltType, typename propType>
430 tlp::AbstractVectorProperty<vectType, eltType, propType>::AbstractVectorProperty(tlp::Graph* g, const std::string& name) :AbstractProperty<vectType, vectType, propType>(g, name) {}
431 //============================================================
432 template <typename vectType, typename eltType, typename propType>
433 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeStringValueAsVector(const node n, const std::string& s, char openChar, char sepChar, char closeChar) {
434  typename vectType::RealType v;
435  std::istringstream iss(s);
436 
437  if (!vectType::read(iss, v, openChar, sepChar, closeChar))
438  return false;
439 
440  this->setNodeValue(n, v);
441  return true;
442 }
443 //============================================================
444 template <typename vectType, typename eltType, typename propType>
445 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeStringValueAsVector(const edge e, const std::string& s, char openChar, char sepChar, char closeChar) {
446  typename vectType::RealType v;
447  std::istringstream iss(s);
448 
449  if (!vectType::read(iss, v, openChar, sepChar, closeChar))
450  return false;
451 
452  this->setEdgeValue(e, v);
453  return true;
454 }
455 //============================================================
456 template <typename vectType, typename eltType, typename propType>
457 void tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeEltValue(const node n, unsigned int i, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
458  assert(n.isValid());
459  bool isNotDefault;
460  typename vectType::RealType& vect =
462  assert(vect.size() > i);
463  this->propType::notifyBeforeSetNodeValue(n);
464 
465  if (isNotDefault)
466  vect[i] = v;
467  else {
468  typename vectType::RealType tmp(vect);
469  tmp[i] = v;
471  }
472 
473  this->propType::notifyAfterSetNodeValue(n);
474 }
475 //============================================================
476 template <typename vectType, typename eltType, typename propType>
477 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
478 tlp::AbstractVectorProperty<vectType, eltType, propType>::getNodeEltValue(const node n, unsigned int i) const {
479  assert(n.isValid());
480  const typename vectType::RealType& vect =
482  assert(vect.size() > i);
483  return vect[i];
484 }
485 //============================================================
486 template <typename vectType, typename eltType, typename propType>
487 void tlp::AbstractVectorProperty<vectType, eltType, propType>::pushBackNodeEltValue(const node n, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
488  assert(n.isValid());
489  bool isNotDefault;
490  typename vectType::RealType& vect =
492  this->propType::notifyBeforeSetNodeValue(n);
493 
494  if (isNotDefault)
495  vect.push_back(v);
496  else {
497  typename vectType::RealType tmp(vect);
498  tmp.push_back(v);
500  }
501 
502  this->propType::notifyAfterSetNodeValue(n);
503 }
504 //============================================================
505 template <typename vectType, typename eltType, typename propType>
506 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackNodeEltValue(const node n) {
507  assert(n.isValid());
508  bool isNotDefault;
509  typename vectType::RealType& vect =
511  this->propType::notifyBeforeSetNodeValue(n);
512  assert(isNotDefault);
513  vect.pop_back();
514  this->propType::notifyAfterSetNodeValue(n);
515 }
516 //============================================================
517 template <typename vectType, typename eltType, typename propType>
518 void tlp::AbstractVectorProperty<vectType, eltType, propType>::resizeNodeValue(const node n, size_t size, typename eltType::RealType elt) {
519  assert(n.isValid());
520  bool isNotDefault;
521  typename vectType::RealType& vect =
523  assert(isNotDefault);
524  this->propType::notifyBeforeSetNodeValue(n);
525  vect.resize(size, elt);
526  this->propType::notifyAfterSetNodeValue(n);
527 }
528 //============================================================
529 template <typename vectType, typename eltType, typename propType>
530 void tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeEltValue(const edge e, unsigned int i, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
531  assert(e.isValid());
532  bool isNotDefault;
533  typename vectType::RealType& vect =
535  assert(vect.size() > i);
536  this->propType::notifyBeforeSetEdgeValue(e);
537 
538  if (isNotDefault)
539  vect[i] = v;
540  else {
541  typename vectType::RealType tmp(vect);
542  tmp[i] = v;
544  }
545 
546  this->propType::notifyAfterSetEdgeValue(e);
547 }
548 //============================================================
549 template <typename vectType, typename eltType, typename propType>
550 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
551 tlp::AbstractVectorProperty<vectType, eltType, propType>::getEdgeEltValue(const edge e, unsigned int i) const {
552  assert(e.isValid());
553  const typename vectType::RealType& vect =
555  assert(vect.size() > i);
556  return vect[i];
557 }//============================================================
558 template <typename vectType, typename eltType, typename propType>
559 void tlp::AbstractVectorProperty<vectType, eltType, propType>::pushBackEdgeEltValue(const edge e, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
560  assert(e.isValid());
561  bool isNotDefault;
562  typename vectType::RealType& vect =
564  this->propType::notifyBeforeSetEdgeValue(e);
565 
566  if (isNotDefault)
567  vect.push_back(v);
568  else {
569  typename vectType::RealType tmp(vect);
570  tmp.push_back(v);
572  }
573 
574  this->propType::notifyAfterSetEdgeValue(e);
575 }
576 //============================================================
577 template <typename vectType, typename eltType, typename propType>
578 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackEdgeEltValue(const edge e) {
579  assert(e.isValid());
580  bool isNotDefault;
581  typename vectType::RealType& vect =
583  this->propType::notifyBeforeSetEdgeValue(e);
584  assert(isNotDefault);
585  vect.pop_back();
586  this->propType::notifyAfterSetEdgeValue(e);
587 }
588 //============================================================
589 template <typename vectType, typename eltType, typename propType>
590 void tlp::AbstractVectorProperty<vectType, eltType, propType>::resizeEdgeValue(const edge e, size_t size, typename eltType::RealType elt) {
591  assert(e.isValid());
592  bool isNotDefault;
593  typename vectType::RealType& vect =
595  assert(isNotDefault);
596  this->propType::notifyBeforeSetEdgeValue(e);
597  vect.resize(size, elt);
598  this->propType::notifyAfterSetEdgeValue(e);
599 }
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue getNodeValue(const node n) const
Returns the value associated with the node n in this property. If there is no value, it returns the default node value.
virtual tlp::Iterator< edge > * getEdgesEqualTo(typename tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue v, const Graph *g=NULL) const
virtual void setAllEdgeValue(typename tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue v)
Sets the value of all edges and notify the observers. All previous values are lost and the given valu...
virtual void setValueToGraphNodes(typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v, const Graph *graph)
Sets the value of all nodes in a graph and notify the observers. Only the nodes from that graph will ...
bool isValid() const
isValid checks if the node is valid. An invalid node is a node whose id is UINT_MAX.
Definition: Node.h:90
virtual const std::vector< edge > & edges() const =0
Return a const reference on the vector of edges of the graph It is the fastest way to access to edges...
virtual const std::vector< node > & nodes() const =0
Return a const reference on the vector of nodes of the graph It is the fastest way to access to nodes...
Tnode::RealType getNodeDefaultValue() const
Gets the default node value of the property.
virtual void setAllNodeValue(typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v)
Sets the value of all nodes and notify the observers. All previous values are lost and the given valu...
The edge struct represents an edge in a Graph object.
Definition: Edge.h:39
The node struct represents a node in a Graph object.
Definition: Node.h:39
virtual void setNodeDefaultValue(typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v)
Sets the value assigned as the default one to the future added nodes.
bool isValid() const
isValid checks if the edge is valid. An invalid edge is an edge whose id is UINT_MAX.
Definition: Edge.h:90
tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue getEdgeValue(const edge e) const
Returns the value associated to the edge e in this property. If there is no value, it returns the default edge value.
Tedge::RealType getEdgeDefaultValue() const
Gets the default edge value of the property.
virtual void setEdgeDefaultValue(typename tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue v)
Sets the value assigned as the default one to the future added edges.
unsigned int id
id The identifier of the node.
Definition: Node.h:43
virtual void setEdgeValue(const edge e, typename tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue v)
Set the value of an edge and notify the observers of a modification.
virtual tlp::Iterator< node > * getNodesEqualTo(typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v, const Graph *g=NULL) const
virtual void setNodeValue(const node n, typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v)
Sets the value of a node and notify the observers of a modification.
unsigned int id
id The identifier of the edge.
Definition: Edge.h:43
virtual void setValueToGraphEdges(typename tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue v, const Graph *graph)
Sets the value of all edges in a graph and notify the observers. Only the edges from that graph will ...