Tulip  5.7.3
Large graphs analysis and drawing
AbstractProperty.h
1 /*
2  *
3  * This file is part of Tulip (https://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 5.0
164  *
165  * @param v The value to set to all nodes.
166  * @param graph A graph that defines the set of nodes
167  *
168  *
169  * @warning If the provided graph is not a descendant of the one associated to that property
170  *(including itself),
171  * no node value will be modified.
172  *
173  **/
174  virtual void
175  setValueToGraphNodes(typename tlp::StoredType<typename Tnode::RealType>::ReturnedConstValue v,
176  const Graph *graph);
177 
178  /**
179  * @brief Sets the value assigned as the default one to the future added edges.
180  *
181  * @since Tulip 5.0
182  *
183  * @param value the new value to set on future added edges.
184  *
185  * @return Whether the given string was a correct representation for this property's type. If not,
186  * the default value is not set.
187  */
188  virtual void
189  setEdgeDefaultValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
190 
191  /**
192  * @brief Sets the value of all edges and notify the observers.
193  * All previous values are lost and the given value is assigned as the default one to the future
194  *added edges.
195  *
196  * @param v The value to set to all edges.
197  *
198  **/
199  virtual void
200  setAllEdgeValue(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v);
201 
202  /**
203  * @brief Sets the value of all edges in a graph and notify the observers.
204  * Only the edges from that graph will have their value modified in the property
205  * and the default edge value will not be modified.
206  *
207  * @since Tulip 5.0
208  *
209  * @param v The value to set to all edges.
210  * @param graph A graph on which to modify
211  *
212  *
213  * @warning If the provided graph is not a descendant of the one associated to that property
214  *(including itself),
215  * no edge value will be modified.
216  *
217  **/
218  virtual void
219  setValueToGraphEdges(typename tlp::StoredType<typename Tedge::RealType>::ReturnedConstValue v,
220  const Graph *graph);
221  //=================================================================================
222 
223  /**
224  * @brief Resets the value of a node to the default value.
225  *
226  * @param n The node to reset the value of.
227  *
228  **/
229  inline void erase(const node n) override {
230  setNodeValue(n, nodeDefaultValue);
231  }
232  //=================================================================================
233 
234  /**
235  * @brief Resets the value of an edge to the default value.
236  *
237  * @param e The edge to reset the value of.
238  *
239  **/
240  inline void erase(const edge e) override {
241  setEdgeValue(e, edgeDefaultValue);
242  }
243  //=================================================================================
244  /**
245  * @brief This operator overload allows to copy a property using the following syntax :
246  *
247  * @code
248  * IntegerProperty* shape = graph->getProperty<IntegerProperty>("viewShape");
249  * IntegerProperty* backup = graph->getProperty<IntegerProperty>("shapeBackup");
250  * *backup = *shape; // all the values from 'shape' will be copied into 'backup'.
251  * @endcode
252  * @param prop The property to copy the values from.
253  * @return This property with the values copied.
254  */
257  if (this != &prop) {
258  if (Tprop::graph == nullptr)
259  Tprop::graph = prop.Tprop::graph;
260 
261  if (Tprop::graph == prop.Tprop::graph) {
262  setAllNodeValue(prop.getNodeDefaultValue());
263  setAllEdgeValue(prop.getEdgeDefaultValue());
264 
265  for (auto itn : prop.getNonDefaultValuatedNodes()) {
266  setNodeValue(itn, prop.getNodeValue(itn));
267  }
268 
269  for (auto ite : prop.getNonDefaultValuatedEdges()) {
270  setEdgeValue(ite, prop.getEdgeValue(ite));
271  }
272 
273  } else {
274  //==============================================================*
275  for (auto n : Tprop::graph->nodes()) {
276  if (prop.Tprop::graph->isElement(n))
277  setNodeValue(n, prop.getNodeValue(n));
278  }
279 
280  for (auto e : Tprop::graph->edges()) {
281  if (prop.Tprop::graph->isElement(e))
282  setEdgeValue(e, prop.getEdgeValue(e));
283  }
284  }
285 
286  clone_handler(prop);
287  }
288 
289  return *this;
290  }
291  //=================================================================================
292  // Untyped accessors inherited from PropertyInterface, documentation is inherited
293  std::string getNodeDefaultStringValue() const override {
294  typename Tnode::RealType v = getNodeDefaultValue();
295  return Tnode::toString(v);
296  }
297  std::string getEdgeDefaultStringValue() const override {
298  typename Tedge::RealType v = getEdgeDefaultValue();
299  return Tedge::toString(v);
300  }
301  std::string getNodeStringValue(const node n) const override {
302  typename Tnode::RealType v = getNodeValue(n);
303  return Tnode::toString(v);
304  }
305  std::string getEdgeStringValue(const edge e) const override {
306  typename Tedge::RealType v = getEdgeValue(e);
307  return Tedge::toString(v);
308  }
309  bool setNodeStringValue(const node inN, const std::string &inV) override {
310  typename Tnode::RealType v;
311 
312  if (!Tnode::fromString(v, inV))
313  return false;
314 
315  setNodeValue(inN, v);
316  return true;
317  }
318  bool setEdgeStringValue(const edge inE, const std::string &inV) override {
319  typename Tedge::RealType v;
320 
321  if (!Tedge::fromString(v, inV))
322  return false;
323 
324  setEdgeValue(inE, v);
325  return true;
326  }
327  bool setNodeDefaultStringValue(const std::string &inV) override {
328  typename Tnode::RealType v;
329 
330  if (!Tnode::fromString(v, inV))
331  return false;
332 
333  setNodeDefaultValue(v);
334  return true;
335  }
336  bool setAllNodeStringValue(const std::string &inV) override {
337  typename Tnode::RealType v;
338 
339  if (!Tnode::fromString(v, inV))
340  return false;
341 
342  setAllNodeValue(v);
343  return true;
344  }
345  bool setStringValueToGraphNodes(const std::string &inV, const Graph *graph) override {
346  typename Tnode::RealType v;
347 
348  if (!Tnode::fromString(v, inV))
349  return false;
350 
351  setValueToGraphNodes(v, graph);
352  return true;
353  }
354  bool setEdgeDefaultStringValue(const std::string &inV) override {
355  typename Tedge::RealType v;
356 
357  if (!Tedge::fromString(v, inV))
358  return false;
359 
360  setEdgeDefaultValue(v);
361  return true;
362  }
363  bool setAllEdgeStringValue(const std::string &inV) override {
364  typename Tedge::RealType v;
365 
366  if (!Tedge::fromString(v, inV))
367  return false;
368 
369  setAllEdgeValue(v);
370  return true;
371  }
372  bool setStringValueToGraphEdges(const std::string &inV, const Graph *graph) override {
373  typename Tedge::RealType v;
374 
375  if (!Tedge::fromString(v, inV))
376  return false;
377 
378  setValueToGraphEdges(v, graph);
379  return true;
380  }
381  tlp::Iterator<node> *getNonDefaultValuatedNodes(const Graph *g = nullptr) const override;
382  bool hasNonDefaultValuatedNodes(const Graph *g = nullptr) const override;
383  unsigned int numberOfNonDefaultValuatedNodes(const Graph *g = nullptr) const override;
384  unsigned int nodeValueSize() const override;
385  void writeNodeDefaultValue(std::ostream &) const override;
386  void writeNodeValue(std::ostream &, node) const override;
387  bool readNodeDefaultValue(std::istream &) override;
388  bool readNodeValue(std::istream &, node) override;
389  tlp::Iterator<edge> *getNonDefaultValuatedEdges(const Graph *g = nullptr) const override;
390  bool hasNonDefaultValuatedEdges(const Graph *g = nullptr) const override;
391  unsigned int numberOfNonDefaultValuatedEdges(const Graph * = nullptr) const override;
392  unsigned int edgeValueSize() const override;
393  void writeEdgeDefaultValue(std::ostream &) const override;
394  void writeEdgeValue(std::ostream &, edge) const override;
395  bool readEdgeDefaultValue(std::istream &) override;
396  bool readEdgeValue(std::istream &, edge) override;
397  bool copy(const node destination, const node source, PropertyInterface *property,
398  bool ifNotDefault = false) override {
399  if (property == nullptr)
400  return false;
401 
403  dynamic_cast<tlp::AbstractProperty<Tnode, Tedge, Tprop> *>(property);
404  assert(tp);
405  bool notDefault;
406  typename StoredType<typename Tnode::RealType>::ReturnedValue value =
407  tp->nodeProperties.get(source.id, notDefault);
408 
409  if (ifNotDefault && !notDefault)
410  return false;
411 
412  setNodeValue(destination, value);
413  return true;
414  }
415  bool copy(const edge destination, const edge source, PropertyInterface *property,
416  bool ifNotDefault = false) override {
417  if (property == nullptr)
418  return false;
419 
421  dynamic_cast<tlp::AbstractProperty<Tnode, Tedge, Tprop> *>(property);
422  assert(tp);
423  bool notDefault;
424  typename StoredType<typename Tedge::RealType>::ReturnedValue value =
425  tp->edgeProperties.get(source.id, notDefault);
426 
427  if (ifNotDefault && !notDefault)
428  return false;
429 
430  setEdgeValue(destination, value);
431  return true;
432  }
433  void copy(PropertyInterface *property) override {
435  dynamic_cast<typename tlp::AbstractProperty<Tnode, Tedge, Tprop> *>(property);
436  assert(prop != nullptr);
437  *this = *prop;
438  }
439  // for performance reason and use in GraphUpdatesRecorder
440  DataMem *getNodeDefaultDataMemValue() const override {
441  return new TypedValueContainer<typename Tnode::RealType>(getNodeDefaultValue());
442  }
443  DataMem *getEdgeDefaultDataMemValue() const override {
444  return new TypedValueContainer<typename Tedge::RealType>(getEdgeDefaultValue());
445  }
446  DataMem *getNodeDataMemValue(const node n) const override {
447  return new TypedValueContainer<typename Tnode::RealType>(getNodeValue(n));
448  }
449  DataMem *getEdgeDataMemValue(const edge e) const override {
450  return new TypedValueContainer<typename Tedge::RealType>(getEdgeValue(e));
451  }
452  DataMem *getNonDefaultDataMemValue(const node n) const override {
453  bool notDefault;
454  typename StoredType<typename Tnode::RealType>::ReturnedValue value =
455  nodeProperties.get(n.id, notDefault);
456 
457  if (notDefault)
458  return new TypedValueContainer<typename Tnode::RealType>(value);
459 
460  return nullptr;
461  }
462  DataMem *getNonDefaultDataMemValue(const edge e) const override {
463  bool notDefault;
464  typename StoredType<typename Tedge::RealType>::ReturnedValue value =
465  edgeProperties.get(e.id, notDefault);
466 
467  if (notDefault)
468  return new TypedValueContainer<typename Tedge::RealType>(value);
469 
470  return nullptr;
471  }
472  void setNodeDataMemValue(const node n, const DataMem *v) override {
473  setNodeValue(n, static_cast<const TypedValueContainer<typename Tnode::RealType> *>(v)->value);
474  }
475  void setEdgeDataMemValue(const edge e, const DataMem *v) override {
476  setEdgeValue(e, static_cast<const TypedValueContainer<typename Tedge::RealType> *>(v)->value);
477  }
478  void setAllNodeDataMemValue(const DataMem *v) override {
479  setAllNodeValue(static_cast<const TypedValueContainer<typename Tnode::RealType> *>(v)->value);
480  }
481  void setAllEdgeDataMemValue(const DataMem *v) override {
482  setAllEdgeValue(static_cast<const TypedValueContainer<typename Tedge::RealType> *>(v)->value);
483  }
484 
485  // PropertyInterface methods
486  // mN is the meta node, sg is the corresponding subgraph
487  // and mg is the graph owning mN
488  void computeMetaValue(node n, Graph *sg, Graph *mg) override {
489  if (Tprop::metaValueCalculator)
491  Tprop::metaValueCalculator)
492  ->computeMetaValue(this, n, sg, mg);
493  }
494  // mE is the meta edge, itE is an iterator on the underlying edges
495  // mg is the graph owning mE
496  void computeMetaValue(edge e, tlp::Iterator<edge> *itE, Graph *mg) override {
497  if (Tprop::metaValueCalculator)
499  Tprop::metaValueCalculator)
500  ->computeMetaValue(this, e, itE, mg);
501  }
503  if (mvCalc &&
505  mvCalc)) {
506  tlp::warning()
507  << "Warning : " << __PRETTY_FUNCTION__ << " ... invalid conversion of "
508  << typeid(mvCalc).name() << "into "
510  .name()
511  << std::endl;
512  abort();
513  }
514 
515  Tprop::metaValueCalculator = mvCalc;
516  }
517 
518  int compare(const node n1, const node n2) const override;
519  int compare(const edge e1, const edge e2) const override;
520 
521  /**
522  * @brief This class is used to delegate the computation of the values associated to meta nodes or
523  *edges.
524  **/
526  public:
527  // computes the value of the meta node mN of the graph mg
528  // for the property prop, according to the values associated
529  // to the underlying nodes i.e the nodes of the subgraph sg.
530  virtual void computeMetaValue(AbstractProperty<Tnode, Tedge, Tprop> *, node, Graph *, Graph *) {
531  }
532  // computes the value of the meta node mE of the graph mg
533  // for the property prop, according to the values associated
534  // to the underlying edges given by the iterator itE.
535  // The method do not have to delete the iterator
536  virtual void computeMetaValue(AbstractProperty<Tnode, Tedge, Tprop> *, edge,
537  tlp::Iterator<edge> *, Graph *) {}
538  };
539 
540 protected:
541  //=================================================================================
542  /// Enable to clone part of sub_class
544 
545  MutableContainer<typename Tnode::RealType> nodeProperties;
546  MutableContainer<typename Tedge::RealType> edgeProperties;
547  typename Tnode::RealType nodeDefaultValue;
548  typename Tedge::RealType edgeDefaultValue;
549 };
550 
551 template <typename vectType, typename eltType, typename propType = VectorPropertyInterface>
552 class TLP_SCOPE AbstractVectorProperty : public AbstractProperty<vectType, vectType, propType> {
553 public:
554  AbstractVectorProperty(Graph *, const std::string &name = "");
555  using AbstractProperty<vectType, vectType, propType>::operator=;
556 
557  // 5 methods inherited from VectorPropertyInterface
558  bool tokenize(const std::string &str, std::vector<std::string> &vect, char openChar = '(',
559  char sepChar = ',', char closeChar = ')') override;
560 
561  bool setNodeStringValueAsVector(const node n, const std::vector<std::string> &values) override;
562 
563  bool setNodeStringValueAsVector(const node, const std::string &, char, char, char) override;
564 
565  bool setEdgeStringValueAsVector(const edge e, const std::vector<std::string> &values) override;
566 
567  bool setEdgeStringValueAsVector(const edge, const std::string &, char, char, char) override;
568 
569  /**
570  * @brief Sets the value for node n, at index i, to v, and notify the observers of a modification.
571  *
572  * @param n The node to set a value of.
573  * @param i The index at which the value should be set.
574  * @param v The value to set.
575  *
576  **/
577  void setNodeEltValue(const node n, unsigned int i,
578  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
579  /**
580  * @brief Gets the value associated to node n, at index i.
581  *
582  * @param n The node to set a value of.
583  * @param i The index at which to set the value.
584  * @return const eltType& The value at index i in the vector for node n.
585  **/
586  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
587  getNodeEltValue(const node n, unsigned int i) const;
588  /**
589  * @brief Appends a new value at the end of the vector associated to node n, and notify the
590  *observers of a modification.
591  *
592  * @param n The node to add a value to.
593  * @param v The value to append at the end of the vector.
594  *
595  **/
596  void
597  pushBackNodeEltValue(const node n,
598  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
599  /**
600  * @brief Removes the value at the end of the vector associated to node n, and notify the
601  *observers of a modification.
602  *
603  * @param n The node to remove a value from.
604  *
605  **/
606  void popBackNodeEltValue(const node n);
607  /**
608  * @brief Resizes the vector associated to node n, and notify the observers of a modification.
609  *
610  * @param n The node associated to the vector to resize.
611  * @param size The new size of the vector.
612  * @param elt The default value to set at indices where there was no value before. Defaults to
613  *eltType().
614  *
615  **/
616  void resizeNodeValue(const node n, size_t size,
617  typename eltType::RealType elt = eltType::defaultValue());
618  /**
619  * @brief Sets the value for edge e, at index i, to v, and notify the observers of a modification.
620  *
621  * @param e The edge to set the value of.
622  * @param i The index at which the value should be set.
623  * @param v The value to set.
624  *
625  **/
626  void setEdgeEltValue(const edge e, unsigned int i,
627  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
628  /**
629  * @brief Gets the value associated to edge e, at index i.
630  *
631  * @param e The edge to set a value of.
632  * @param i The index at which to set the value.
633  * @return const eltType& The value at index i in the vector for node n.
634  **/
635  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue
636  getEdgeEltValue(const edge n, unsigned int i) const;
637  /**
638  * @brief Appends a new value at the end of the vector associated to edge e, and notify the
639  *observers of a modification.
640  *
641  * @param e The node to add a value to.
642  * @param v The value to append at the end of the vector.
643  *
644  **/
645  void
646  pushBackEdgeEltValue(const edge e,
647  typename tlp::StoredType<typename eltType::RealType>::ReturnedConstValue v);
648  /**
649  * @brief Removes the value at the end of the vector associated to edge e, and notify the
650  *observers of a modification.
651  *
652  * @param e The edge to remove a value from.
653  *
654  **/
655  void popBackEdgeEltValue(const edge e);
656  /**
657  * @brief Resizes the vector associated to edge e, and notify the observers of a modification.
658  *
659  * @param e The edge associated to the vector to resize.
660  * @param size The new size of the vector.
661  * @param elt The default value to set at indices where there was no value before. Defaults to
662  *eltType().
663  *
664  **/
665  void resizeEdgeValue(const edge e, size_t size,
666  typename eltType::RealType elt = eltType::defaultValue());
667 };
668 } // namespace tlp
669 #if !defined(_MSC_VER) || defined(DLL_TULIP) // When using VC++, we only want to include this when
670  // we are in the TULIP dll. With any other compiler,
671  // include it all the time
672 #include "cxx/AbstractProperty.cxx"
673 #endif
674 #endif
This class is used to delegate the computation of the values associated to meta nodes or edges.
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
void erase(const edge e) override
Resets the value of an edge to the default value.
virtual void clone_handler(AbstractProperty< Tnode, Tedge, Tprop > &)
Enable to clone part of sub_class.
bool setNodeStringValue(const node inN, const std::string &inV) override
Sets a new value on the node, represented by the string parameter.
void setNodeDataMemValue(const node n, const DataMem *v) override
Sets the node value.
bool setStringValueToGraphNodes(const std::string &inV, const Graph *graph) override
Sets all the nodes value to the value represented by the string for a graph. For some types,...
tlp::Iterator< node > * getNonDefaultValuatedNodes(const Graph *g=nullptr) const override
Gets an Iterator on all non-default valuated nodes. When given a Graph as parameter,...
void setMetaValueCalculator(PropertyInterface::MetaValueCalculator *mvCalc) override
Sets the Calculator for meta nodes and edges.
bool setAllNodeStringValue(const std::string &inV) override
Sets all the nodes value to the value represented by the string. For some types, some parsing will be...
void setEdgeDataMemValue(const edge e, const DataMem *v) override
Sets the edge value.
bool setStringValueToGraphEdges(const std::string &inV, const Graph *graph) override
Sets all the edges value to the value represented by the string for a graph. For some types,...
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,...
virtual AbstractProperty< Tnode, Tedge, Tprop > & operator=(AbstractProperty< Tnode, Tedge, Tprop > &prop)
This operator overload allows to copy a property using the following syntax :
DataMem * getNodeDefaultDataMemValue() const override
Gets a pointer to the tlp::DataMem structure that contains the node default value.
bool setEdgeStringValue(const edge inE, const std::string &inV) override
Sets a new value on the edge, represented by the string parameter.
void setAllNodeDataMemValue(const DataMem *v) override
Sets all the nodes value to the value contained in the given DataMem structure. All previous values a...
void computeMetaValue(node n, Graph *sg, Graph *mg) override
Sets the value of the metanode to a computed value.
bool setAllEdgeStringValue(const std::string &inV) override
Sets all the edges value to the value represented by the string. For some types, some parsing will be...
bool setNodeDefaultStringValue(const std::string &inV) override
Sets the value assigned as the default one to the future added nodes from a string representation.
std::string getNodeDefaultStringValue() const override
Gets a string representation of the node default value.
DataMem * getEdgeDataMemValue(const edge e) const override
Gets the edge value, contained in a tlp::DataMem structure.
void setAllEdgeDataMemValue(const DataMem *v) override
Sets all the edges value to the value contained in the given DataMem structure. All previous values a...
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,...
bool setEdgeDefaultStringValue(const std::string &inV) override
Sets the value assigned as the default one to the future added edges from a string representation.
std::string getNodeStringValue(const node n) const override
Gets a string representation of the node value.
Tnode::RealType getNodeDefaultValue() const
Gets the default node value of the property.
void erase(const node n) override
Resets the value of a node to the default value.
bool copy(const edge destination, const edge source, PropertyInterface *property, bool ifNotDefault=false) override
Copies the value of an edge in another property to an edge in this property.
void computeMetaValue(edge e, tlp::Iterator< edge > *itE, Graph *mg) override
Sets the value of the metaedge to a computed value.
std::string getEdgeStringValue(const edge e) const override
Gets a string representation of the edge value.
DataMem * getNonDefaultDataMemValue(const node n) const override
Returns the value in a DataMem if it is not default, otherwise returns nullptr.
bool copy(const node destination, const node source, PropertyInterface *property, bool ifNotDefault=false) override
Copies the value of a node in another property to a node in this property.
Tedge::RealType getEdgeDefaultValue() const
Gets the default edge value of the property.
void copy(PropertyInterface *property) override
Copies the values of the source property to this property.
tlp::Iterator< edge > * getNonDefaultValuatedEdges(const Graph *g=nullptr) const override
Gets an Iterator on all non-default valuated edges. When given a Graph as parameter,...
DataMem * getNodeDataMemValue(const node n) const override
Gets the node value, contained in a tlp::DataMem structure.
DataMem * getEdgeDefaultDataMemValue() const override
Gets a pointer to the tlp::DataMem structure that contains the edge default value.
std::string getEdgeDefaultStringValue() const override
Gets a string representation of the edge default value.
DataMem * getNonDefaultDataMemValue(const edge e) const override
Returns the value in a DataMem if it is not default, otherwise returns nullptr.
Base class for computing values on meta nodes and edges.
PropertyInterface describes the interface of a graph property.
Interface for Tulip iterators. Allows basic iteration operations only.
Definition: Iterator.h:74
The edge struct represents an edge in a Graph object.
Definition: Edge.h:40
unsigned int id
id The identifier of the edge.
Definition: Edge.h:44
The node struct represents a node in a Graph object.
Definition: Node.h:40
unsigned int id
id The identifier of the node.
Definition: Node.h:44