Tulip  5.3.1
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 *graph) {
165  setValueToGraphNodes(v, graph);
166 }
167 //=============================================================
168 template <class Tnode, class Tedge, class Tprop>
170  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v, const Graph *graph) {
171  if (this->getGraph() == graph || this->getGraph()->isDescendantGraph(graph)) {
172  for (auto n : graph->nodes()) {
173  setNodeValue(n, v);
174  }
175  }
176 }
177 //=============================================================
178 template <class Tnode, class Tedge, class Tprop>
180  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
181  if (edgeDefaultValue == v) {
182  return;
183  }
184 
185  // backup old default value
186  auto oldDefaultValue = edgeDefaultValue;
187  // backup list of edges whose value equals the current default one
188  std::vector<tlp::edge> edgesOldDefaultToUpdate;
189  // backup list of edges whose value equals the new default one
190  std::vector<tlp::edge> edgesDefaultToUpdate;
191 
192  for (auto e : this->getGraph()->edges()) {
193  auto val = edgeProperties.get(e.id);
194 
195  if (val == oldDefaultValue) {
196  edgesOldDefaultToUpdate.push_back(e);
197  } else if (val == v) {
198  edgesDefaultToUpdate.push_back(e);
199  }
200  }
201 
202  // set new default value that will be associated to future added edges
203  edgeDefaultValue = v;
204  edgeProperties.setDefault(v);
205 
206  // reset the backup edges to the old default value as there is a new one in the
207  // underlying MutableContainer
208  for (size_t i = 0; i < edgesOldDefaultToUpdate.size(); ++i) {
209  edgeProperties.set(edgesOldDefaultToUpdate[i].id, oldDefaultValue);
210  }
211 
212  // reset the backup edges to their current value in order
213  // to synchronize the underlying MutableContainer state
214  for (size_t i = 0; i < edgesDefaultToUpdate.size(); ++i) {
215  edgeProperties.set(edgesDefaultToUpdate[i].id, v, true);
216  }
217 }
218 //============================================================
219 template <class Tnode, class Tedge, class Tprop>
221  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v) {
222  Tprop::notifyBeforeSetAllEdgeValue();
223  edgeDefaultValue = v;
224  edgeProperties.setAll(v);
225  Tprop::notifyAfterSetAllEdgeValue();
226 }
227 //============================================================
228 template <class Tnode, class Tedge, class Tprop>
230  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *graph) {
231  setValueToGraphEdges(v, graph);
232 }
233 //============================================================
234 template <class Tnode, class Tedge, class Tprop>
236  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v, const Graph *graph) {
237  if (this->getGraph() == graph || this->getGraph()->isDescendantGraph(graph)) {
238  for (auto e : graph->edges()) {
239  setEdgeValue(e, v);
240  }
241  }
242 }
243 //============================================================
244 template <class Tnode, class Tedge, class Tprop>
245 int tlp::AbstractProperty<Tnode, Tedge, Tprop>::compare(const node n1, const node n2) const {
246  const typename Tnode::RealType &n1Value = getNodeValue(n1);
247  const typename Tnode::RealType &n2Value = getNodeValue(n2);
248  return (n1Value < n2Value) ? -1 : ((n1Value == n2Value) ? 0 : 1);
249 }
250 //============================================================
251 template <class Tnode, class Tedge, class Tprop>
252 int tlp::AbstractProperty<Tnode, Tedge, Tprop>::compare(const edge e1, const edge e2) const {
253  const typename Tedge::RealType &e1Value = getEdgeValue(e1);
254  const typename Tedge::RealType &e2Value = getEdgeValue(e2);
255  return (e1Value < e2Value) ? -1 : ((e1Value == e2Value) ? 0 : 1);
256 }
257 //============================================================
258 // define template iterator class to iterate over graph elts
259 // belonging to a given graph instance
260 // used by the two methods below
261 ///@cond DOXYGEN_HIDDEN
262 template <typename ELT_TYPE>
263 class GraphEltIterator : public tlp::Iterator<ELT_TYPE> {
264 public:
265  ELT_TYPE next() override {
266  ELT_TYPE tmp = curElt;
267 
268  if ((_hasnext = it->hasNext())) {
269  curElt = it->next();
270 
271  while (!(_hasnext = (!graph || graph->isElement(curElt)))) {
272  if (!it->hasNext())
273  break;
274 
275  curElt = it->next();
276  }
277  }
278 
279  return tmp;
280  }
281  GraphEltIterator(const tlp::Graph *g, tlp::Iterator<ELT_TYPE> *itN)
282  : it(itN), graph(g), curElt(ELT_TYPE()), _hasnext(false) {
283  next();
284  }
285 
286  bool hasNext() override {
287  return (_hasnext);
288  }
289  ~GraphEltIterator() override {
290  delete it;
291  }
292 
293 private:
295  const tlp::Graph *graph;
296  ELT_TYPE curElt;
297  bool _hasnext;
298 };
299 ///@endcond
300 
301 //============================================================
302 template <class Tnode, class Tedge, class Tprop>
306  new tlp::UINTIterator<tlp::node>(nodeProperties.findAll(nodeDefaultValue, false));
307 
308  if (Tprop::name.empty())
309  // we always need to check that nodes belong to graph
310  // for non registered properties, because deleted nodes are not erased
311  // from them
312  return new GraphEltIterator<tlp::node>(g != nullptr ? g : Tprop::graph, it);
313 
314  return ((g == nullptr) || (g == Tprop::graph)) ? it : new GraphEltIterator<tlp::node>(g, it);
315 }
316 //============================================================
317 template <class Tnode, class Tedge, class Tprop>
319  if (g == nullptr) {
320  return nodeProperties.hasNonDefaultValues();
321  } else {
322  return !tlp::iteratorEmpty(getNonDefaultValuatedNodes(g));
323  }
324 }
325 //============================================================
326 template <class Tnode, class Tedge, class Tprop>
327 unsigned int
329  if (g == nullptr) {
330  return nodeProperties.numberOfNonDefaultValues();
331  } else {
332  return tlp::iteratorCount(getNonDefaultValuatedNodes(g));
333  }
334 }
335 //============================================================
336 template <class Tnode, class Tedge, class Tprop>
338  return Tnode::valueSize();
339 }
340 //============================================================
341 template <class Tnode, class Tedge, class Tprop>
343  Tnode::writeb(oss, nodeDefaultValue);
344 }
345 //============================================================
346 template <class Tnode, class Tedge, class Tprop>
347 void tlp::AbstractProperty<Tnode, Tedge, Tprop>::writeNodeValue(std::ostream &oss, node n) const {
348  assert(n.isValid());
349  Tnode::writeb(oss, nodeProperties.get(n.id));
350 }
351 //============================================================
352 template <class Tnode, class Tedge, class Tprop>
354  if (Tnode::readb(iss, nodeDefaultValue)) {
355  nodeProperties.setAll(nodeDefaultValue);
356  return true;
357  }
358 
359  return false;
360 }
361 //============================================================
362 template <class Tnode, class Tedge, class Tprop>
364  typename Tnode::RealType val;
365 
366  if (Tnode::readb(iss, val)) {
367  nodeProperties.set(n.id, val);
368  return true;
369  }
370 
371  return false;
372 }
373 //============================================================
374 template <class Tnode, class Tedge, class Tprop>
378  new tlp::UINTIterator<tlp::edge>(edgeProperties.findAll(edgeDefaultValue, false));
379 
380  if (Tprop::name.empty())
381  // we always need to check that edges belong to graph
382  // for non registered properties, because deleted edges are not erased
383  // from them
384  return new GraphEltIterator<tlp::edge>(g != nullptr ? g : Tprop::graph, it);
385 
386  return ((g == nullptr) || (g == Tprop::graph)) ? it : new GraphEltIterator<tlp::edge>(g, it);
387 }
388 //============================================================
389 template <class Tnode, class Tedge, class Tprop>
391  if (g == nullptr) {
392  return edgeProperties.hasNonDefaultValues();
393  } else {
394  return !tlp::iteratorEmpty(getNonDefaultValuatedEdges(g));
395  }
396 }
397 //============================================================
398 template <class Tnode, class Tedge, class Tprop>
399 unsigned int
401  if (g == nullptr) {
402  return edgeProperties.numberOfNonDefaultValues();
403  } else {
404  return tlp::iteratorCount(getNonDefaultValuatedEdges(g));
405  }
406 }
407 //============================================================
408 template <class Tnode, class Tedge, class Tprop>
410  return Tedge::valueSize();
411 }
412 //============================================================
413 template <class Tnode, class Tedge, class Tprop>
415  Tedge::writeb(oss, edgeDefaultValue);
416 }
417 //============================================================
418 template <class Tnode, class Tedge, class Tprop>
419 void tlp::AbstractProperty<Tnode, Tedge, Tprop>::writeEdgeValue(std::ostream &oss, edge e) const {
420  assert(e.isValid());
421  Tedge::writeb(oss, edgeProperties.get(e.id));
422 }
423 //============================================================
424 template <class Tnode, class Tedge, class Tprop>
426  if (Tedge::readb(iss, edgeDefaultValue)) {
427  edgeProperties.setAll(edgeDefaultValue);
428  return true;
429  }
430 
431  return false;
432 }
433 //============================================================
434 template <class Tnode, class Tedge, class Tprop>
436  typename Tedge::RealType val;
437 
438  if (Tedge::readb(iss, val)) {
439  edgeProperties.set(e.id, val);
440  return true;
441  }
442 
443  return false;
444 }
445 //============================================================
446 template <typename vectType, typename eltType, typename propType>
447 tlp::AbstractVectorProperty<vectType, eltType, propType>::AbstractVectorProperty(
448  tlp::Graph *g, const std::string &name)
450 //============================================================
451 template <typename vectType, typename eltType, typename propType>
452 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::tokenize(
453  const std::string &s, std::vector<std::string> &vect, char openChar, char sepChar,
454  char closeChar) {
455  return vectType::tokenize(s, vect, openChar, sepChar, closeChar);
456 }
457 //============================================================
458 template <typename vectType, typename eltType, typename propType>
459 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeStringValueAsVector(
460  const node n, const std::vector<std::string> &vs) {
461  typename vectType::RealType v;
462  if (!vectType::read(vs, v))
463  return false;
464 
465  this->setNodeValue(n, v);
466  return true;
467 }
468 //============================================================
469 template <typename vectType, typename eltType, typename propType>
470 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeStringValueAsVector(
471  const node n, const std::string &s, char openChar, char sepChar, char closeChar) {
472  typename vectType::RealType v;
473  std::istringstream iss(s);
474 
475  if (!vectType::read(iss, v, openChar, sepChar, closeChar))
476  return false;
477 
478  this->setNodeValue(n, v);
479  return true;
480 }
481 //============================================================
482 template <typename vectType, typename eltType, typename propType>
483 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeStringValueAsVector(
484  const edge e, const std::vector<std::string> &vs) {
485  typename vectType::RealType v;
486  if (!vectType::read(vs, v))
487  return false;
488 
489  this->setEdgeValue(e, v);
490  return true;
491 }
492 //============================================================
493 template <typename vectType, typename eltType, typename propType>
494 bool tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeStringValueAsVector(
495  const edge e, const std::string &s, char openChar, char sepChar, char closeChar) {
496  typename vectType::RealType v;
497  std::istringstream iss(s);
498 
499  if (!vectType::read(iss, v, openChar, sepChar, closeChar))
500  return false;
501 
502  this->setEdgeValue(e, v);
503  return true;
504 }
505 //============================================================
506 template <typename vectType, typename eltType, typename propType>
507 void tlp::AbstractVectorProperty<vectType, eltType, propType>::setNodeEltValue(
508  const node n, unsigned int i,
509  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
510  assert(n.isValid());
511  bool isNotDefault;
512  typename vectType::RealType &vect =
514  assert(vect.size() > i);
515  this->propType::notifyBeforeSetNodeValue(n);
516 
517  if (isNotDefault)
518  vect[i] = v;
519  else {
520  typename vectType::RealType tmp(vect);
521  tmp[i] = v;
523  }
524 
525  this->propType::notifyAfterSetNodeValue(n);
526 }
527 //============================================================
528 template <typename vectType, typename eltType, typename propType>
529 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
530 tlp::AbstractVectorProperty<vectType, eltType, propType>::getNodeEltValue(const node n,
531  unsigned int i) const {
532  assert(n.isValid());
533  const typename vectType::RealType &vect =
535  assert(vect.size() > i);
536  return vect[i];
537 }
538 //============================================================
539 template <typename vectType, typename eltType, typename propType>
540 void tlp::AbstractVectorProperty<vectType, eltType, propType>::pushBackNodeEltValue(
541  const node n, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
542  assert(n.isValid());
543  bool isNotDefault;
544  typename vectType::RealType &vect =
546  this->propType::notifyBeforeSetNodeValue(n);
547 
548  if (isNotDefault)
549  vect.push_back(v);
550  else {
551  typename vectType::RealType tmp(vect);
552  tmp.push_back(v);
554  }
555 
556  this->propType::notifyAfterSetNodeValue(n);
557 }
558 //============================================================
559 template <typename vectType, typename eltType, typename propType>
560 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackNodeEltValue(const node n) {
561  assert(n.isValid());
562  bool isNotDefault;
563  typename vectType::RealType &vect =
565  this->propType::notifyBeforeSetNodeValue(n);
566  assert(isNotDefault);
567  vect.pop_back();
568  this->propType::notifyAfterSetNodeValue(n);
569 }
570 //============================================================
571 template <typename vectType, typename eltType, typename propType>
572 void tlp::AbstractVectorProperty<vectType, eltType, propType>::resizeNodeValue(
573  const node n, size_t size, typename eltType::RealType elt) {
574  assert(n.isValid());
575  bool isNotDefault;
576  typename vectType::RealType &vect =
578  assert(isNotDefault);
579  this->propType::notifyBeforeSetNodeValue(n);
580  vect.resize(size, elt);
581  this->propType::notifyAfterSetNodeValue(n);
582 }
583 //============================================================
584 template <typename vectType, typename eltType, typename propType>
585 void tlp::AbstractVectorProperty<vectType, eltType, propType>::setEdgeEltValue(
586  const edge e, unsigned int i,
587  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
588  assert(e.isValid());
589  bool isNotDefault;
590  typename vectType::RealType &vect =
592  assert(vect.size() > i);
593  this->propType::notifyBeforeSetEdgeValue(e);
594 
595  if (isNotDefault)
596  vect[i] = v;
597  else {
598  typename vectType::RealType tmp(vect);
599  tmp[i] = v;
601  }
602 
603  this->propType::notifyAfterSetEdgeValue(e);
604 }
605 //============================================================
606 template <typename vectType, typename eltType, typename propType>
607 typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
608 tlp::AbstractVectorProperty<vectType, eltType, propType>::getEdgeEltValue(const edge e,
609  unsigned int i) const {
610  assert(e.isValid());
611  const typename vectType::RealType &vect =
613  assert(vect.size() > i);
614  return vect[i];
615 } //============================================================
616 template <typename vectType, typename eltType, typename propType>
617 void tlp::AbstractVectorProperty<vectType, eltType, propType>::pushBackEdgeEltValue(
618  const edge e, typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v) {
619  assert(e.isValid());
620  bool isNotDefault;
621  typename vectType::RealType &vect =
623  this->propType::notifyBeforeSetEdgeValue(e);
624 
625  if (isNotDefault)
626  vect.push_back(v);
627  else {
628  typename vectType::RealType tmp(vect);
629  tmp.push_back(v);
631  }
632 
633  this->propType::notifyAfterSetEdgeValue(e);
634 }
635 //============================================================
636 template <typename vectType, typename eltType, typename propType>
637 void tlp::AbstractVectorProperty<vectType, eltType, propType>::popBackEdgeEltValue(const edge e) {
638  assert(e.isValid());
639  bool isNotDefault;
640  typename vectType::RealType &vect =
642  this->propType::notifyBeforeSetEdgeValue(e);
643  assert(isNotDefault);
644  vect.pop_back();
645  this->propType::notifyAfterSetEdgeValue(e);
646 }
647 //============================================================
648 template <typename vectType, typename eltType, typename propType>
649 void tlp::AbstractVectorProperty<vectType, eltType, propType>::resizeEdgeValue(
650  const edge e, size_t size, typename eltType::RealType elt) {
651  assert(e.isValid());
652  bool isNotDefault;
653  typename vectType::RealType &vect =
655  assert(isNotDefault);
656  this->propType::notifyBeforeSetEdgeValue(e);
657  vect.resize(size, elt);
658  this->propType::notifyAfterSetEdgeValue(e);
659 }
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 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 ...