Tulip  5.4.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/BasicIterators.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 = nullptr;
31 }
32 //=============================================================
33 template <class Tnode, class Tedge, class Tprop>
34 inline typename Tnode::RealType
36  return nodeDefaultValue;
37 }
38 //=============================================================
39 template <class Tnode, class Tedge, class Tprop>
40 inline typename Tedge::RealType
42  return edgeDefaultValue;
43 }
44 //=============================================================
45 template <class Tnode, class Tedge, class Tprop>
46 inline typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue
48  assert(n.isValid());
49  return nodeProperties.get(n.id);
50 }
51 //=============================================================
52 template <class Tnode, class Tedge, class Tprop>
53 inline typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue
55  assert(e.isValid());
56  return edgeProperties.get(e.id);
57 }
58 //=================================================================================
59 template <class Tnode, class Tedge, class Tprop>
61  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue val,
62  const Graph *sg) const {
63  if (sg == nullptr)
64  sg = this->graph;
65 
66  tlp::Iterator<unsigned int> *it = nullptr;
67 
68  if (sg == this->graph)
69  it = nodeProperties.findAll(val);
70 
71  if (it == nullptr)
72  return new tlp::SGraphNodeIterator<typename Tnode::RealType>(sg, nodeProperties, val);
73 
74  return (new tlp::UINTIterator<node>(it));
75 }
76 //=================================================================================
77 template <class Tnode, class Tedge, class Tprop>
79  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue val,
80  const Graph *sg) const {
81  if (sg == nullptr)
82  sg = this->graph;
83 
84  tlp::Iterator<unsigned int> *it = nullptr;
85 
86  if (sg == this->graph)
87  it = edgeProperties.findAll(val);
88 
89  if (it == nullptr)
90  return new tlp::SGraphEdgeIterator<typename Tedge::RealType>(sg, edgeProperties, val);
91 
92  return (new tlp::UINTIterator<edge>(it));
93 }
94 //=============================================================
95 template <class Tnode, class Tedge, class Tprop>
97  const tlp::node n, typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v) {
98  assert(n.isValid());
99  Tprop::notifyBeforeSetNodeValue(n);
100  nodeProperties.set(n.id, v);
101  Tprop::notifyAfterSetNodeValue(n);
102 }
103 //=============================================================
104 template <class Tnode, class Tedge, class Tprop>
106  const tlp::edge e, typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
107  assert(e.isValid());
108  Tprop::notifyBeforeSetEdgeValue(e);
109  edgeProperties.set(e.id, v);
110  Tprop::notifyAfterSetEdgeValue(e);
111 }
112 //=============================================================
113 template <class Tnode, class Tedge, class Tprop>
115  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v) {
116  Tprop::notifyBeforeSetAllNodeValue();
117  nodeDefaultValue = v;
118  nodeProperties.setAll(v);
119  Tprop::notifyAfterSetAllNodeValue();
120 }
121 //=============================================================
122 template <class Tnode, class Tedge, class Tprop>
124  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v) {
125  if (nodeDefaultValue == v) {
126  return;
127  }
128 
129  // backup old default value
130  auto oldDefaultValue = nodeDefaultValue;
131  // we need to get the list of nodes whose value equals the current default one first
132  std::vector<tlp::node> nodesOldDefaultToUpdate;
133  std::vector<tlp::node> nodesDefaultToUpdate;
134 
135  for (auto n : this->getGraph()->nodes()) {
136  auto val = nodeProperties.get(n.id);
137 
138  if (val == oldDefaultValue) {
139  nodesOldDefaultToUpdate.push_back(n);
140  } else if (val == v) {
141  nodesDefaultToUpdate.push_back(n);
142  }
143  }
144 
145  // set new default value that will be associated to future added nodes
146  nodeDefaultValue = v;
147  nodeProperties.setDefault(v);
148 
149  // reset the backup nodes to the old default value as there is a new one in the
150  // underlying MutableContainer
151  for (size_t i = 0; i < nodesOldDefaultToUpdate.size(); ++i) {
152  nodeProperties.set(nodesOldDefaultToUpdate[i].id, oldDefaultValue);
153  }
154 
155  // reset the backup nodes to their current value in order
156  // to synchronize the underlying MutableContainer state
157  for (size_t i = 0; i < nodesDefaultToUpdate.size(); ++i) {
158  nodeProperties.set(nodesDefaultToUpdate[i].id, v, true);
159  }
160 }
161 //=============================================================
162 template <class Tnode, class Tedge, class Tprop>
164  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *g) {
165  auto graph = this->getGraph();
166  if (v == nodeDefaultValue) {
167  // speedup update if v is the default value
168  if (graph == g)
169  setAllNodeValue(v);
170  else if (graph->isDescendantGraph(g)) {
171  auto it = getNonDefaultValuatedNodes(g);
172  while (it->hasNext()) {
173  setNodeValue(it->next(), v);
174  }
175  delete it;
176  }
177  } else if (graph == g || graph->isDescendantGraph(g)) {
178  for (auto n : g->nodes()) {
179  setNodeValue(n, v);
180  }
181  }
182 }
183 //=============================================================
184 template <class Tnode, class Tedge, class Tprop>
186  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
187  if (edgeDefaultValue == v) {
188  return;
189  }
190 
191  // backup old default value
192  auto oldDefaultValue = edgeDefaultValue;
193  // backup list of edges whose value equals the current default one
194  std::vector<tlp::edge> edgesOldDefaultToUpdate;
195  // backup list of edges whose value equals the new default one
196  std::vector<tlp::edge> edgesDefaultToUpdate;
197 
198  for (auto e : this->getGraph()->edges()) {
199  auto val = edgeProperties.get(e.id);
200 
201  if (val == oldDefaultValue) {
202  edgesOldDefaultToUpdate.push_back(e);
203  } else if (val == v) {
204  edgesDefaultToUpdate.push_back(e);
205  }
206  }
207 
208  // set new default value that will be associated to future added edges
209  edgeDefaultValue = v;
210  edgeProperties.setDefault(v);
211 
212  // reset the backup edges to the old default value as there is a new one in the
213  // underlying MutableContainer
214  for (size_t i = 0; i < edgesOldDefaultToUpdate.size(); ++i) {
215  edgeProperties.set(edgesOldDefaultToUpdate[i].id, oldDefaultValue);
216  }
217 
218  // reset the backup edges to their current value in order
219  // to synchronize the underlying MutableContainer state
220  for (size_t i = 0; i < edgesDefaultToUpdate.size(); ++i) {
221  edgeProperties.set(edgesDefaultToUpdate[i].id, v, true);
222  }
223 }
224 //============================================================
225 template <class Tnode, class Tedge, class Tprop>
227  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
228  Tprop::notifyBeforeSetAllEdgeValue();
229  edgeDefaultValue = v;
230  edgeProperties.setAll(v);
231  Tprop::notifyAfterSetAllEdgeValue();
232 }
233 //============================================================
234 template <class Tnode, class Tedge, class Tprop>
236  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *g) {
237  auto graph = this->getGraph();
238  if (v == edgeDefaultValue) {
239  // speedup update if v is the default value
240  if (graph == g)
241  setAllEdgeValue(v);
242  else if (graph->isDescendantGraph(g)) {
243  auto it = getNonDefaultValuatedEdges(g);
244  while (it->hasNext()) {
245  setEdgeValue(it->next(), v);
246  }
247  delete it;
248  }
249  } else if (graph == g || graph->isDescendantGraph(g)) {
250  for (auto e : g->edges()) {
251  setEdgeValue(e, v);
252  }
253  }
254 }
255 //============================================================
256 template <class Tnode, class Tedge, class Tprop>
257 int tlp::AbstractProperty<Tnode, Tedge, Tprop>::compare(const node n1, const node n2) const {
258  const typename Tnode::RealType &n1Value = getNodeValue(n1);
259  const typename Tnode::RealType &n2Value = getNodeValue(n2);
260  return (n1Value < n2Value) ? -1 : ((n1Value == n2Value) ? 0 : 1);
261 }
262 //============================================================
263 template <class Tnode, class Tedge, class Tprop>
264 int tlp::AbstractProperty<Tnode, Tedge, Tprop>::compare(const edge e1, const edge e2) const {
265  const typename Tedge::RealType &e1Value = getEdgeValue(e1);
266  const typename Tedge::RealType &e2Value = getEdgeValue(e2);
267  return (e1Value < e2Value) ? -1 : ((e1Value == e2Value) ? 0 : 1);
268 }
269 //============================================================
270 // define template iterator class to iterate over graph elts
271 // belonging to a given graph instance
272 // used by the two methods below
273 ///@cond DOXYGEN_HIDDEN
274 template <typename ELT_TYPE>
275 class GraphEltIterator : public tlp::Iterator<ELT_TYPE> {
276 public:
277  ELT_TYPE next() override {
278  ELT_TYPE tmp = curElt;
279 
280  if ((_hasnext = it->hasNext())) {
281  curElt = it->next();
282 
283  while (!(_hasnext = (!graph || graph->isElement(curElt)))) {
284  if (!it->hasNext())
285  break;
286 
287  curElt = it->next();
288  }
289  }
290 
291  return tmp;
292  }
293  GraphEltIterator(const tlp::Graph *g, tlp::Iterator<ELT_TYPE> *itN)
294  : it(itN), graph(g), curElt(ELT_TYPE()), _hasnext(false) {
295  next();
296  }
297 
298  bool hasNext() override {
299  return (_hasnext);
300  }
301  ~GraphEltIterator() override {
302  delete it;
303  }
304 
305 private:
307  const tlp::Graph *graph;
308  ELT_TYPE curElt;
309  bool _hasnext;
310 };
311 ///@endcond
312 
313 //============================================================
314 template <class Tnode, class Tedge, class Tprop>
318  new tlp::UINTIterator<tlp::node>(nodeProperties.findAll(nodeDefaultValue, false));
319 
320  if (Tprop::name.empty())
321  // we always need to check that nodes belong to graph
322  // for non registered properties, because deleted nodes are not erased
323  // from them
324  return new GraphEltIterator<tlp::node>(g != nullptr ? g : Tprop::graph, it);
325 
326  return ((g == nullptr) || (g == Tprop::graph)) ? it : new GraphEltIterator<tlp::node>(g, it);
327 }
328 //============================================================
329 template <class Tnode, class Tedge, class Tprop>
331  if (g == nullptr) {
332  return nodeProperties.hasNonDefaultValues();
333  } else {
334  return !tlp::iteratorEmpty(getNonDefaultValuatedNodes(g));
335  }
336 }
337 //============================================================
338 template <class Tnode, class Tedge, class Tprop>
339 unsigned int
341  if (g == nullptr) {
342  return nodeProperties.numberOfNonDefaultValues();
343  } else {
344  return tlp::iteratorCount(getNonDefaultValuatedNodes(g));
345  }
346 }
347 //============================================================
348 template <class Tnode, class Tedge, class Tprop>
350  return Tnode::valueSize();
351 }
352 //============================================================
353 template <class Tnode, class Tedge, class Tprop>
355  Tnode::writeb(oss, nodeDefaultValue);
356 }
357 //============================================================
358 template <class Tnode, class Tedge, class Tprop>
359 void tlp::AbstractProperty<Tnode, Tedge, Tprop>::writeNodeValue(std::ostream &oss, node n) const {
360  assert(n.isValid());
361  Tnode::writeb(oss, nodeProperties.get(n.id));
362 }
363 //============================================================
364 template <class Tnode, class Tedge, class Tprop>
366  if (Tnode::readb(iss, nodeDefaultValue)) {
367  nodeProperties.setAll(nodeDefaultValue);
368  return true;
369  }
370 
371  return false;
372 }
373 //============================================================
374 template <class Tnode, class Tedge, class Tprop>
376  typename Tnode::RealType val;
377 
378  if (Tnode::readb(iss, val)) {
379  nodeProperties.set(n.id, val);
380  return true;
381  }
382 
383  return false;
384 }
385 //============================================================
386 template <class Tnode, class Tedge, class Tprop>
390  new tlp::UINTIterator<tlp::edge>(edgeProperties.findAll(edgeDefaultValue, false));
391 
392  if (Tprop::name.empty())
393  // we always need to check that edges belong to graph
394  // for non registered properties, because deleted edges are not erased
395  // from them
396  return new GraphEltIterator<tlp::edge>(g != nullptr ? g : Tprop::graph, it);
397 
398  return ((g == nullptr) || (g == Tprop::graph)) ? it : new GraphEltIterator<tlp::edge>(g, it);
399 }
400 //============================================================
401 template <class Tnode, class Tedge, class Tprop>
403  if (g == nullptr) {
404  return edgeProperties.hasNonDefaultValues();
405  } else {
406  return !tlp::iteratorEmpty(getNonDefaultValuatedEdges(g));
407  }
408 }
409 //============================================================
410 template <class Tnode, class Tedge, class Tprop>
411 unsigned int
413  if (g == nullptr) {
414  return edgeProperties.numberOfNonDefaultValues();
415  } else {
416  return tlp::iteratorCount(getNonDefaultValuatedEdges(g));
417  }
418 }
419 //============================================================
420 template <class Tnode, class Tedge, class Tprop>
422  return Tedge::valueSize();
423 }
424 //============================================================
425 template <class Tnode, class Tedge, class Tprop>
427  Tedge::writeb(oss, edgeDefaultValue);
428 }
429 //============================================================
430 template <class Tnode, class Tedge, class Tprop>
431 void tlp::AbstractProperty<Tnode, Tedge, Tprop>::writeEdgeValue(std::ostream &oss, edge e) const {
432  assert(e.isValid());
433  Tedge::writeb(oss, edgeProperties.get(e.id));
434 }
435 //============================================================
436 template <class Tnode, class Tedge, class Tprop>
438  if (Tedge::readb(iss, edgeDefaultValue)) {
439  edgeProperties.setAll(edgeDefaultValue);
440  return true;
441  }
442 
443  return false;
444 }
445 //============================================================
446 template <class Tnode, class Tedge, class Tprop>
448  typename Tedge::RealType val;
449 
450  if (Tedge::readb(iss, val)) {
451  edgeProperties.set(e.id, val);
452  return true;
453  }
454 
455  return false;
456 }
457 //============================================================
458 template <typename vectType, typename eltType, typename propType>
459 tlp::AbstractVectorProperty<vectType, eltType, propType>::AbstractVectorProperty(
460  tlp::Graph *g, const std::string &name)
462 //============================================================
463 template <typename vectType, typename eltType, typename propType>
464 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::tokenize(
465  const std::string &s, std::vector<std::string> &vect, char openChar, char sepChar,
466  char closeChar) {
467  return vectType::tokenize(s, vect, openChar, sepChar, closeChar);
468 }
469 //============================================================
470 template <typename vectType, typename eltType, typename propType>
471 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeStringValueAsVector(
472  const node n, const std::vector<std::string> &vs) {
473  typename vectType::RealType v;
474  if (!vectType::read(vs, v))
475  return false;
476 
477  this->setNodeValue(n, v);
478  return true;
479 }
480 //============================================================
481 template <typename vectType, typename eltType, typename propType>
482 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeStringValueAsVector(
483  const node n, const std::string &s, char openChar, char sepChar, char closeChar) {
484  typename vectType::RealType v;
485  std::istringstream iss(s);
486 
487  if (!vectType::read(iss, v, openChar, sepChar, closeChar))
488  return false;
489 
490  this->setNodeValue(n, v);
491  return true;
492 }
493 //============================================================
494 template <typename vectType, typename eltType, typename propType>
495 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeStringValueAsVector(
496  const edge e, const std::vector<std::string> &vs) {
497  typename vectType::RealType v;
498  if (!vectType::read(vs, v))
499  return false;
500 
501  this->setEdgeValue(e, v);
502  return true;
503 }
504 //============================================================
505 template <typename vectType, typename eltType, typename propType>
506 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeStringValueAsVector(
507  const edge e, const std::string &s, char openChar, char sepChar, char closeChar) {
508  typename vectType::RealType v;
509  std::istringstream iss(s);
510 
511  if (!vectType::read(iss, v, openChar, sepChar, closeChar))
512  return false;
513 
514  this->setEdgeValue(e, v);
515  return true;
516 }
517 //============================================================
518 template <typename vectType, typename eltType, typename propType>
519 void tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeEltValue(
520  const node n, unsigned int i,
521  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
522  assert(n.isValid());
523  bool isNotDefault;
524  typename vectType::RealType &vect =
526  assert(vect.size() > i);
527  this->propType::notifyBeforeSetNodeValue(n);
528 
529  if (isNotDefault)
530  vect[i] = v;
531  else {
532  typename vectType::RealType tmp(vect);
533  tmp[i] = v;
535  }
536 
537  this->propType::notifyAfterSetNodeValue(n);
538 }
539 //============================================================
540 template <typename vectType, typename eltType, typename propType>
541 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
542 tlp::AbstractVectorProperty<vectType, eltType, propType>::getNodeEltValue(const node n,
543  unsigned int i) const {
544  assert(n.isValid());
545  const typename vectType::RealType &vect =
547  assert(vect.size() > i);
548  return vect[i];
549 }
550 //============================================================
551 template <typename vectType, typename eltType, typename propType>
552 void tlp::AbstractVectorProperty<vectType, eltType, propType>::pushBackNodeEltValue(
553  const node n, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
554  assert(n.isValid());
555  bool isNotDefault;
556  typename vectType::RealType &vect =
558  this->propType::notifyBeforeSetNodeValue(n);
559 
560  if (isNotDefault)
561  vect.push_back(v);
562  else {
563  typename vectType::RealType tmp(vect);
564  tmp.push_back(v);
566  }
567 
568  this->propType::notifyAfterSetNodeValue(n);
569 }
570 //============================================================
571 template <typename vectType, typename eltType, typename propType>
572 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackNodeEltValue(const node n) {
573  assert(n.isValid());
574  bool isNotDefault;
575  typename vectType::RealType &vect =
577  this->propType::notifyBeforeSetNodeValue(n);
578  assert(isNotDefault);
579  vect.pop_back();
580  this->propType::notifyAfterSetNodeValue(n);
581 }
582 //============================================================
583 template <typename vectType, typename eltType, typename propType>
584 void tlp::AbstractVectorProperty<vectType, eltType, propType>::resizeNodeValue(
585  const node n, size_t size, typename eltType::RealType elt) {
586  assert(n.isValid());
587  bool isNotDefault;
588  typename vectType::RealType &vect =
590  assert(isNotDefault);
591  this->propType::notifyBeforeSetNodeValue(n);
592  vect.resize(size, elt);
593  this->propType::notifyAfterSetNodeValue(n);
594 }
595 //============================================================
596 template <typename vectType, typename eltType, typename propType>
597 void tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeEltValue(
598  const edge e, unsigned int i,
599  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
600  assert(e.isValid());
601  bool isNotDefault;
602  typename vectType::RealType &vect =
604  assert(vect.size() > i);
605  this->propType::notifyBeforeSetEdgeValue(e);
606 
607  if (isNotDefault)
608  vect[i] = v;
609  else {
610  typename vectType::RealType tmp(vect);
611  tmp[i] = v;
613  }
614 
615  this->propType::notifyAfterSetEdgeValue(e);
616 }
617 //============================================================
618 template <typename vectType, typename eltType, typename propType>
619 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
620 tlp::AbstractVectorProperty<vectType, eltType, propType>::getEdgeEltValue(const edge e,
621  unsigned int i) const {
622  assert(e.isValid());
623  const typename vectType::RealType &vect =
625  assert(vect.size() > i);
626  return vect[i];
627 } //============================================================
628 template <typename vectType, typename eltType, typename propType>
629 void tlp::AbstractVectorProperty<vectType, eltType, propType>::pushBackEdgeEltValue(
630  const edge e, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
631  assert(e.isValid());
632  bool isNotDefault;
633  typename vectType::RealType &vect =
635  this->propType::notifyBeforeSetEdgeValue(e);
636 
637  if (isNotDefault)
638  vect.push_back(v);
639  else {
640  typename vectType::RealType tmp(vect);
641  tmp.push_back(v);
643  }
644 
645  this->propType::notifyAfterSetEdgeValue(e);
646 }
647 //============================================================
648 template <typename vectType, typename eltType, typename propType>
649 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackEdgeEltValue(const edge e) {
650  assert(e.isValid());
651  bool isNotDefault;
652  typename vectType::RealType &vect =
654  this->propType::notifyBeforeSetEdgeValue(e);
655  assert(isNotDefault);
656  vect.pop_back();
657  this->propType::notifyAfterSetEdgeValue(e);
658 }
659 //============================================================
660 template <typename vectType, typename eltType, typename propType>
661 void tlp::AbstractVectorProperty<vectType, eltType, propType>::resizeEdgeValue(
662  const edge e, size_t size, typename eltType::RealType elt) {
663  assert(e.isValid());
664  bool isNotDefault;
665  typename vectType::RealType &vect =
667  assert(isNotDefault);
668  this->propType::notifyBeforeSetEdgeValue(e);
669  vect.resize(size, elt);
670  this->propType::notifyAfterSetEdgeValue(e);
671 }
bool iteratorEmpty(Iterator< T > *it)
Checks if an iterator is empty.
Definition: Iterator.h:227
unsigned int iteratorCount(Iterator< T > *it)
Counts the number of iterated elements.
Definition: Iterator.h:175
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
virtual T next()=0
Moves the Iterator on the next element.
Tedge::RealType getEdgeDefaultValue() const
Gets the default edge value of the property.
virtual bool isDescendantGraph(const Graph *subGraph) const =0
Indicates if the graph argument is a descendant of this graph.
virtual tlp::Iterator< node > * getNodesEqualTo(typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v, const Graph *g=nullptr) 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...
Tnode::RealType getNodeDefaultValue() const
Gets the default node value of the property.
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 ...
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...
bool isValid() const
isValid checks if the edge is valid. An invalid edge is an edge whose id is UINT_MAX.
Definition: Edge.h:92
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...
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.
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.
The edge struct represents an edge in a Graph object.
Definition: Edge.h:40
The node struct represents a node in a Graph object.
Definition: Node.h:40
virtual void setNodeDefaultValue(typename tlp::StoredType< typename Tnode::RealType >::ReturnedConstValue v)
Sets the value assigned as the default one to the future added nodes.
virtual tlp::Iterator< edge > * getEdgesEqualTo(typename tlp::StoredType< typename Tedge::RealType >::ReturnedConstValue v, const Graph *g=nullptr) const
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:44
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.
bool isValid() const
isValid checks if the node is valid. An invalid node is a node whose id is UINT_MAX.
Definition: Node.h:92
virtual bool hasNext()=0
Tells if the sequence is at its end.
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:44
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 ...