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