Tulip  5.3.1
Large graphs analysis and drawing
AbstractProperty.h
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 
20 #ifndef ABSTRACT_PROPERTY_H
21 #define ABSTRACT_PROPERTY_H
22 
23 #include <typeinfo>
24 #include <string>
25 #include <cstdlib>
26 #include <tulip/tulipconf.h>
27 #include <tulip/StoredType.h>
28 #include <tulip/MutableContainer.h>
29 #include <tulip/PropertyInterface.h>
30 #include <tulip/Iterator.h>
31 #include <tulip/DataSet.h>
32 #include <tulip/Graph.h>
33 
34 namespace tlp {
35 
36 class GraphView;
37 
38 //==============================================================
39 
40 /**
41  * @ingroup Graph
42  * @brief This class extends upon PropertyInterface, and adds type-safe methods to
43  * get and set the node and edge values, through the magic of template programming.
44  *
45  * Nodes and Edges can have different types (e.g. tlp::LayoutProperty has tlp::PointType as node
46  * type and tlp::LineType as edge type),
47  * but most of the time they have the same type (e.g. tlp::DoubleProperty, tlp::IntegerProperty).
48  *
49  * Some of the pure virtual functions of PropertyInterface are implemented in this class (e.g.
50  * erase()).
51  *
52  * The actual data is stored in this class, and it manages the default values.
53  */
54 template <class Tnode, class Tedge, class Tprop = PropertyInterface>
55 class TLP_SCOPE AbstractProperty : public Tprop {
56  friend class Graph;
57  friend class GraphView;
58 
59 public:
60  AbstractProperty(Graph *, const std::string &n = "");
61 
62  /**
63  * @brief Gets the default node value of the property.
64  * @return The default value of nodes.
65  */
66  typename Tnode::RealType getNodeDefaultValue() const;
67 
68  /**
69  * @brief Gets the default edge value of the property.
70  * @return The default value of edges.
71  **/
72  typename Tedge::RealType getEdgeDefaultValue() const;
73 
74  /**
75  * @brief Returns the value associated with the node n in this property.
76  * If there is no value, it returns the default node value.
77  *
78  * @param n The node for which we want to get the value of the property.
79  * @return :StoredType< Tnode::RealType >::ReturnedConstValue The value of the property for this
80  *node.
81  **/
82  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue
83  getNodeValue(const node n) const;
84 
85  /**
86  * @brief Returns the value associated to the edge e in this property.
87  * If there is no value, it returns the default edge value.
88  *
89  * @param e The edge for which we want to get the value of the property.
90  * @return :StoredType< Tedge::RealType >::ReturnedConstValue The value of the property for this
91  *edge.
92  **/
93  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue
94  getEdgeValue(const edge e) const;
95 
96  /**
97  * Returns an iterator through all nodes belonging to g
98  * whose associated value is equal to val.
99  * If g is nullptr, the graph given when creating the property is considered.
100  */
101  virtual tlp::Iterator<node> *
102  getNodesEqualTo(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v,
103  const Graph *g = nullptr) const;
104 
105  /**
106  * Returns an iterator through all edges belonging to g
107  * whose associated value is equal to val.
108  * If g is nullptr, the graph given when creating the property is considered.
109  */
110  virtual tlp::Iterator<edge> *
111  getEdgesEqualTo(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v,
112  const Graph *g = nullptr) const;
113 
114  /**
115  * @brief Sets the value of a node and notify the observers of a modification.
116  *
117  * @param n The node to set the value of.
118  * @param v The value to affect for this node.
119  **/
120  virtual void
121  setNodeValue(const node n,
122  typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v);
123 
124  /**
125  * @brief Set the value of an edge and notify the observers of a modification.
126  *
127  * @param e The edge to set the value of.
128  * @param v The value to affect for this edge.
129  **/
130  virtual void
131  setEdgeValue(const edge e,
132  typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
133 
134  /**
135  * @brief Sets the value of all nodes and notify the observers.
136  * All previous values are lost and the given value is assigned as the default one to the future
137  *added nodes.
138  *
139  * @param v The value to set to all nodes.
140  *
141  **/
142  virtual void
143  setAllNodeValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v);
144 
145  /**
146  * @brief Sets the value assigned as the default one to the future added nodes.
147  *
148  * @since Tulip 5.0
149  *
150  * @param v the new value to set on future added nodes.
151  *
152  * @return Whether the given string was a correct representation for this property's type. If not,
153  * the default value is not set.
154  */
155  virtual void
156  setNodeDefaultValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v);
157 
158  /**
159  * @brief Sets the value of all nodes in a graph and notify the observers.
160  * Only the nodes from that graph will have their value modified in the property
161  * and the default node value will not be modified.
162  *
163  * @since Tulip 4.10
164  *
165  * @deprecated Since Tulip 5.0 this method signature is deprecated, use method
166  *setValueToGraphNodes instead
167  *
168  * @param v The value to set to all nodes.
169  * @param graph A graph that defines the set of nodes
170  *
171  *
172  * @warning If the provided graph is not a descendant of the one associated to that property
173  *(including itself),
174  * no node value will be modified.
175  *
176  **/
177  _DEPRECATED virtual void
178  setAllNodeValue(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v,
179  const Graph *graph);
180 
181  /**
182  * @brief Sets the value of all nodes in a graph and notify the observers.
183  * Only the nodes from that graph will have their value modified in the property
184  * and the default node value will not be modified.
185  *
186  * @since Tulip 5.0
187  *
188  * @param v The value to set to all nodes.
189  * @param graph A graph that defines the set of nodes
190  *
191  *
192  * @warning If the provided graph is not a descendant of the one associated to that property
193  *(including itself),
194  * no node value will be modified.
195  *
196  **/
197  virtual void
198  setValueToGraphNodes(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v,
199  const Graph *graph);
200 
201  /**
202  * @brief Sets the value assigned as the default one to the future added edges.
203  *
204  * @since Tulip 5.0
205  *
206  * @param value the new value to set on future added edges.
207  *
208  * @return Whether the given string was a correct representation for this property's type. If not,
209  * the default value is not set.
210  */
211  virtual void
212  setEdgeDefaultValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
213 
214  /**
215  * @brief Sets the value of all edges and notify the observers.
216  * All previous values are lost and the given value is assigned as the default one to the future
217  *added edges.
218  *
219  * @param v The value to set to all edges.
220  *
221  **/
222  virtual void
223  setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
224 
225  /**
226  * @brief Sets the value of all edges in a graph and notify the observers.
227  * Only the edges from that graph will have their value modified in the property
228  * and the default edge value will not be modified.
229  *
230  * @since Tulip 4.10
231  *
232  * @deprecated Since Tulip 5.0 this method signature is deprecated, use method
233  *setValueToGraphEdges instead
234  *
235  * @param v The value to set to all edges.
236  * @param graph A graph that defines the set of edges
237  *
238  *
239  * @warning If the provided graph is not a descendant of the one associated to that property
240  *(including itself),
241  * no edge value will be modified.
242  *
243  **/
244  _DEPRECATED virtual void
245  setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v,
246  const Graph *graph);
247 
248  /**
249  * @brief Sets the value of all edges in a graph and notify the observers.
250  * Only the edges from that graph will have their value modified in the property
251  * and the default edge value will not be modified.
252  *
253  * @since Tulip 5.0
254  *
255  * @param v The value to set to all edges.
256  * @param graph A graph on which to modify
257  *
258  *
259  * @warning If the provided graph is not a descendant of the one associated to that property
260  *(including itself),
261  * no edge value will be modified.
262  *
263  **/
264  virtual void
265  setValueToGraphEdges(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v,
266  const Graph *graph);
267  //=================================================================================
268 
269  /**
270  * @brief Resets the value of a node to the default value.
271  *
272  * @param n The node to reset the value of.
273  *
274  **/
275  inline void erase(const node n) override {
276  setNodeValue(n, nodeDefaultValue);
277  }
278  //=================================================================================
279 
280  /**
281  * @brief Resets the value of an edge to the default value.
282  *
283  * @param e The edge to reset the value of.
284  *
285  **/
286  inline void erase(const edge e) override {
287  setEdgeValue(e, edgeDefaultValue);
288  }
289  //=================================================================================
290  /**
291  * @brief This operator overload allows to copy a property using the following syntax :
292  *
293  * @code
294  * IntegerProperty* shape = graph->getProperty<IntegerProperty>("viewShape");
295  * IntegerProperty* backup = graph->getProperty<IntegerProperty>("shapeBackup");
296  * *backup = *shape; // all the values from 'shape' will be copied into 'backup'.
297  * @endcode
298  * @param prop The property to copy the values from.
299  * @return This property with the values copied.
300  */
303  if (this != &prop) {
304  if (Tprop::graph == nullptr)
305  Tprop::graph = prop.Tprop::graph;
306 
307  if (Tprop::graph == prop.Tprop::graph) {
308  setAllNodeValue(prop.getNodeDefaultValue());
309  setAllEdgeValue(prop.getEdgeDefaultValue());
310 
311  for (auto itn : prop.getNonDefaultValuatedNodes()) {
312  setNodeValue(itn, prop.getNodeValue(itn));
313  }
314 
315  for (auto ite : prop.getNonDefaultValuatedEdges()) {
316  setEdgeValue(ite, prop.getEdgeValue(ite));
317  }
318 
319  } else {
320  //==============================================================*
321  for (auto n : Tprop::graph->nodes()) {
322  if (prop.Tprop::graph->isElement(n))
323  setNodeValue(n, prop.getNodeValue(n));
324  }
325 
326  for (auto e : Tprop::graph->edges()) {
327  if (prop.Tprop::graph->isElement(e))
328  setEdgeValue(e, prop.getEdgeValue(e));
329  }
330  }
331 
332  clone_handler(prop);
333  }
334 
335  return *this;
336  }
337  //=================================================================================
338  // Untyped accessors inherited from PropertyInterface, documentation is inherited
339  std::string getNodeDefaultStringValue() const override {
340  typename Tnode::RealType v = getNodeDefaultValue();
341  return Tnode::toString(v);
342  }
343  std::string getEdgeDefaultStringValue() const override {
344  typename Tedge::RealType v = getEdgeDefaultValue();
345  return Tedge::toString(v);
346  }
347  std::string getNodeStringValue(const node n) const override {
348  typename Tnode::RealType v = getNodeValue(n);
349  return Tnode::toString(v);
350  }
351  std::string getEdgeStringValue(const edge e) const override {
352  typename Tedge::RealType v = getEdgeValue(e);
353  return Tedge::toString(v);
354  }
355  bool setNodeStringValue(const node inN, const std::string &inV) override {
356  typename Tnode::RealType v;
357 
358  if (!Tnode::fromString(v, inV))
359  return false;
360 
361  setNodeValue(inN, v);
362  return true;
363  }
364  bool setEdgeStringValue(const edge inE, const std::string &inV) override {
365  typename Tedge::RealType v;
366 
367  if (!Tedge::fromString(v, inV))
368  return false;
369 
370  setEdgeValue(inE, v);
371  return true;
372  }
373  bool setNodeDefaultStringValue(const std::string &inV) override {
374  typename Tnode::RealType v;
375 
376  if (!Tnode::fromString(v, inV))
377  return false;
378 
379  setNodeDefaultValue(v);
380  return true;
381  }
382  bool setAllNodeStringValue(const std::string &inV) override {
383  typename Tnode::RealType v;
384 
385  if (!Tnode::fromString(v, inV))
386  return false;
387 
388  setAllNodeValue(v);
389  return true;
390  }
391  _DEPRECATED bool setAllNodeStringValue(const std::string &inV, const Graph *graph) override {
392  return setStringValueToGraphNodes(inV, graph);
393  }
394  bool setStringValueToGraphNodes(const std::string &inV, const Graph *graph) override {
395  typename Tnode::RealType v;
396 
397  if (!Tnode::fromString(v, inV))
398  return false;
399 
400  setValueToGraphNodes(v, graph);
401  return true;
402  }
403  bool setEdgeDefaultStringValue(const std::string &inV) override {
404  typename Tedge::RealType v;
405 
406  if (!Tedge::fromString(v, inV))
407  return false;
408 
409  setEdgeDefaultValue(v);
410  return true;
411  }
412  bool setAllEdgeStringValue(const std::string &inV) override {
413  typename Tedge::RealType v;
414 
415  if (!Tedge::fromString(v, inV))
416  return false;
417 
418  setAllEdgeValue(v);
419  return true;
420  }
421  _DEPRECATED bool setAllEdgeStringValue(const std::string &inV, const Graph *graph) override {
422  return setStringValueToGraphEdges(inV, graph);
423  }
424  bool setStringValueToGraphEdges(const std::string &inV, const Graph *graph) override {
425  typename Tedge::RealType v;
426 
427  if (!Tedge::fromString(v, inV))
428  return false;
429 
430  setValueToGraphEdges(v, graph);
431  return true;
432  }
433  tlp::Iterator<node> *getNonDefaultValuatedNodes(const Graph *g = nullptr) const override;
434  bool hasNonDefaultValuatedNodes(const Graph *g = nullptr) const override;
435  unsigned int numberOfNonDefaultValuatedNodes(const Graph *g = nullptr) const override;
436  unsigned int nodeValueSize() const override;
437  void writeNodeDefaultValue(std::ostream &) const override;
438  void writeNodeValue(std::ostream &, node) const override;
439  bool readNodeDefaultValue(std::istream &) override;
440  bool readNodeValue(std::istream &, node) override;
441  tlp::Iterator<edge> *getNonDefaultValuatedEdges(const Graph *g = nullptr) const override;
442  bool hasNonDefaultValuatedEdges(const Graph *g = nullptr) const override;
443  unsigned int numberOfNonDefaultValuatedEdges(const Graph * = nullptr) const override;
444  unsigned int edgeValueSize() const override;
445  void writeEdgeDefaultValue(std::ostream &) const override;
446  void writeEdgeValue(std::ostream &, edge) const override;
447  bool readEdgeDefaultValue(std::istream &) override;
448  bool readEdgeValue(std::istream &, edge) override;
449  bool copy(const node destination, const node source, PropertyInterface *property,
450  bool ifNotDefault = false) override {
451  if (property == nullptr)
452  return false;
453 
455  dynamic_cast<tlp::AbstractProperty<Tnode, Tedge, Tprop> *>(property);
456  assert(tp);
457  bool notDefault;
458  typename StoredType<typename Tnode::RealType>::ReturnedValue value =
459  tp->nodeProperties.get(source.id, notDefault);
460 
461  if (ifNotDefault && !notDefault)
462  return false;
463 
464  setNodeValue(destination, value);
465  return true;
466  }
467  bool copy(const edge destination, const edge source, PropertyInterface *property,
468  bool ifNotDefault = false) override {
469  if (property == nullptr)
470  return false;
471 
473  dynamic_cast<tlp::AbstractProperty<Tnode, Tedge, Tprop> *>(property);
474  assert(tp);
475  bool notDefault;
476  typename StoredType<typename Tedge::RealType>::ReturnedValue value =
477  tp->edgeProperties.get(source.id, notDefault);
478 
479  if (ifNotDefault && !notDefault)
480  return false;
481 
482  setEdgeValue(destination, value);
483  return true;
484  }
485  void copy(PropertyInterface *property) override {
487  dynamic_cast<typename tlp::AbstractProperty<Tnode, Tedge, Tprop> *>(property);
488  assert(prop != nullptr);
489  *this = *prop;
490  }
491  // for performance reason and use in GraphUpdatesRecorder
492  DataMem *getNodeDefaultDataMemValue() const override {
493  return new TypedValueContainer<typename Tnode::RealType>(getNodeDefaultValue());
494  }
495  DataMem *getEdgeDefaultDataMemValue() const override {
496  return new TypedValueContainer<typename Tedge::RealType>(getEdgeDefaultValue());
497  }
498  DataMem *getNodeDataMemValue(const node n) const override {
499  return new TypedValueContainer<typename Tnode::RealType>(getNodeValue(n));
500  }
501  DataMem *getEdgeDataMemValue(const edge e) const override {
502  return new TypedValueContainer<typename Tedge::RealType>(getEdgeValue(e));
503  }
504  DataMem *getNonDefaultDataMemValue(const node n) const override {
505  bool notDefault;
506  typename StoredType<typename Tnode::RealType>::ReturnedValue value =
507  nodeProperties.get(n.id, notDefault);
508 
509  if (notDefault)
510  return new TypedValueContainer<typename Tnode::RealType>(value);
511 
512  return nullptr;
513  }
514  DataMem *getNonDefaultDataMemValue(const edge e) const override {
515  bool notDefault;
516  typename StoredType<typename Tedge::RealType>::ReturnedValue value =
517  edgeProperties.get(e.id, notDefault);
518 
519  if (notDefault)
520  return new TypedValueContainer<typename Tedge::RealType>(value);
521 
522  return nullptr;
523  }
524  void setNodeDataMemValue(const node n, const DataMem *v) override {
525  setNodeValue(n, static_cast<const TypedValueContainer<typename Tnode::RealType> *>(v)->value);
526  }
527  void setEdgeDataMemValue(const edge e, const DataMem *v) override {
528  setEdgeValue(e, static_cast<const TypedValueContainer<typename Tedge::RealType> *>(v)->value);
529  }
530  void setAllNodeDataMemValue(const DataMem *v) override {
531  setAllNodeValue(static_cast<const TypedValueContainer<typename Tnode::RealType> *>(v)->value);
532  }
533  void setAllEdgeDataMemValue(const DataMem *v) override {
534  setAllEdgeValue(static_cast<const TypedValueContainer<typename Tedge::RealType> *>(v)->value);
535  }
536 
537  // PropertyInterface methods
538  // mN is the meta node, sg is the corresponding subgraph
539  // and mg is the graph owning mN
540  void computeMetaValue(node n, Graph *sg, Graph *mg) override {
541  if (Tprop::metaValueCalculator)
543  Tprop::metaValueCalculator)
544  ->computeMetaValue(this, n, sg, mg);
545  }
546  // mE is the meta edge, itE is an iterator on the underlying edges
547  // mg is the graph owning mE
548  void computeMetaValue(edge e, tlp::Iterator<edge> *itE, Graph *mg) override {
549  if (Tprop::metaValueCalculator)
551  Tprop::metaValueCalculator)
552  ->computeMetaValue(this, e, itE, mg);
553  }
554  void setMetaValueCalculator(PropertyInterface::MetaValueCalculator *mvCalc) override {
555  if (mvCalc &&
557  mvCalc)) {
558  tlp::warning()
559  << "Warning : " << __PRETTY_FUNCTION__ << " ... invalid conversion of "
560  << typeid(mvCalc).name() << "into "
562  .name()
563  << std::endl;
564  abort();
565  }
566 
567  Tprop::metaValueCalculator = mvCalc;
568  }
569 
570  int compare(const node n1, const node n2) const override;
571  int compare(const edge e1, const edge e2) const override;
572 
573  /**
574  * @brief This class is used to delegate the computation of the values associated to meta nodes or
575  *edges.
576  **/
578  public:
579  // computes the value of the meta node mN of the graph mg
580  // for the property prop, according to the values associated
581  // to the underlying nodes i.e the nodes of the subgraph sg.
582  virtual void computeMetaValue(AbstractProperty<Tnode, Tedge, Tprop> *, node, Graph *, Graph *) {
583  }
584  // computes the value of the meta node mE of the graph mg
585  // for the property prop, according to the values associated
586  // to the underlying edges given by the iterator itE.
587  // The method do not have to delete the iterator
588  virtual void computeMetaValue(AbstractProperty<Tnode, Tedge, Tprop> *, edge,
589  tlp::Iterator<edge> *, Graph *) {}
590  };
591 
592 protected:
593  //=================================================================================
594  /// Enable to clone part of sub_class
596 
597  MutableContainer<typename Tnode::RealType> nodeProperties;
598  MutableContainer<typename Tedge::RealType> edgeProperties;
599  typename Tnode::RealType nodeDefaultValue;
600  typename Tedge::RealType edgeDefaultValue;
601 };
602 
603 template <typename vectType, typename eltType, typename propType = VectorPropertyInterface>
604 class TLP_SCOPE AbstractVectorProperty : public AbstractProperty<vectType, vectType, propType> {
605 public:
606  AbstractVectorProperty(Graph *, const std::string &name = "");
607 
608  // 5 methods inherited from VectorPropertyInterface
609  bool tokenize(const std::string &str, std::vector<std::string> &vect, char openChar = '(',
610  char sepChar = ',', char closeChar = ')') override;
611 
612  bool setNodeStringValueAsVector(const node n, const std::vector<std::string> &values) override;
613 
614  bool setNodeStringValueAsVector(const node, const std::string &, char, char, char) override;
615 
616  bool setEdgeStringValueAsVector(const edge e, const std::vector<std::string> &values) override;
617 
618  bool setEdgeStringValueAsVector(const edge, const std::string &, char, char, char) override;
619 
620  /**
621  * @brief Sets the value for node n, at index i, to v, and notify the observers of a modification.
622  *
623  * @param n The node to set a value of.
624  * @param i The index at which the value should be set.
625  * @param v The value to set.
626  *
627  **/
628  void setNodeEltValue(const node n, unsigned int i,
629  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
630  /**
631  * @brief Gets the value associated to node n, at index i.
632  *
633  * @param n The node to set a value of.
634  * @param i The index at which to set the value.
635  * @return const eltType& The value at index i in the vector for node n.
636  **/
637  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
638  getNodeEltValue(const node n, unsigned int i) const;
639  /**
640  * @brief Appends a new value at the end of the vector associated to node n, and notify the
641  *observers of a modification.
642  *
643  * @param n The node to add a value to.
644  * @param v The value to append at the end of the vector.
645  *
646  **/
647  void
648  pushBackNodeEltValue(const node n,
649  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
650  /**
651  * @brief Removes the value at the end of the vector associated to node n, and notify the
652  *observers of a modification.
653  *
654  * @param n The node to remove a value from.
655  *
656  **/
657  void popBackNodeEltValue(const node n);
658  /**
659  * @brief Resizes the vector associated to node n, and notify the observers of a modification.
660  *
661  * @param n The node associated to the vector to resize.
662  * @param size The new size of the vector.
663  * @param elt The default value to set at indices where there was no value before. Defaults to
664  *eltType().
665  *
666  **/
667  void resizeNodeValue(const node n, size_t size,
668  typename eltType::RealType elt = eltType::defaultValue());
669  /**
670  * @brief Sets the value for edge e, at index i, to v, and notify the observers of a modification.
671  *
672  * @param e The edge to set the value of.
673  * @param i The index at which the value should be set.
674  * @param v The value to set.
675  *
676  **/
677  void setEdgeEltValue(const edge e, unsigned int i,
678  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
679  /**
680  * @brief Gets the value associated to edge e, at index i.
681  *
682  * @param e The edge to set a value of.
683  * @param i The index at which to set the value.
684  * @return const eltType& The value at index i in the vector for node n.
685  **/
686  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
687  getEdgeEltValue(const edge n, unsigned int i) const;
688  /**
689  * @brief Appends a new value at the end of the vector associated to edge e, and notify the
690  *observers of a modification.
691  *
692  * @param e The node to add a value to.
693  * @param v The value to append at the end of the vector.
694  *
695  **/
696  void
697  pushBackEdgeEltValue(const edge e,
698  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
699  /**
700  * @brief Removes the value at the end of the vector associated to edge e, and notify the
701  *observers of a modification.
702  *
703  * @param e The edge to remove a value from.
704  *
705  **/
706  void popBackEdgeEltValue(const edge e);
707  /**
708  * @brief Resizes the vector associated to edge e, and notify the observers of a modification.
709  *
710  * @param e The edge associated to the vector to resize.
711  * @param size The new size of the vector.
712  * @param elt The default value to set at indices where there was no value before. Defaults to
713  *eltType().
714  *
715  **/
716  void resizeEdgeValue(const edge e, size_t size,
717  typename eltType::RealType elt = eltType::defaultValue());
718 };
719 } // namespace tlp
720 #if !defined(_MSC_VER) || defined(DLL_TULIP) // When using VC++, we only want to include this when
721  // we are in the TULIP dll. With any other compiler,
722  // include it all the time
723 #include "cxx/AbstractProperty.cxx"
724 #endif
725 #endif
void erase(const edge e) override
Resets the value of an edge to the default value.
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
Tedge::RealType getEdgeDefaultValue() const
Gets the default edge value of the property.
Interface for Tulip iterators. Allows basic iteration operations only.
Definition: Graph.h:43
PropertyInterface describes the interface of a graph property.
virtual AbstractProperty< Tnode, Tedge, Tprop > & operator=(AbstractProperty< Tnode, Tedge, Tprop > &prop)
This operator overload allows to copy a property using the following syntax :
Tnode::RealType getNodeDefaultValue() const
Gets the default node value of the property.
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
void erase(const node n) override
Resets the value of a node to the default value.
This class is used to delegate the computation of the values associated to meta nodes or edges...
Base class for computing values on meta nodes and edges.
virtual void clone_handler(AbstractProperty< Tnode, Tedge, Tprop > &)
Enable to clone part of sub_class.
unsigned int id
id The identifier of the node.
Definition: Node.h:44
unsigned int id
id The identifier of the edge.
Definition: Edge.h:44