20 #ifndef TULIP_METRIC_H 
   21 #define TULIP_METRIC_H 
   23 #include <tulip/PropertyTypes.h> 
   24 #include <tulip/AbstractProperty.h> 
   25 #include <tulip/PropertyAlgorithm.h> 
   26 #include <tulip/minmaxproperty.h> 
   27 #include <tulip/NumericProperty.h> 
   31 class PropertyContext;
 
   33 typedef MinMaxProperty<tlp::DoubleType, tlp::DoubleType, tlp::NumericProperty> DoubleMinMaxProperty;
 
   42   using DoubleMinMaxProperty::operator=;
 
   47   static const std::string propertyTypename;
 
   49     return propertyTypename;
 
   51   DEFINE_GET_CPP_CLASS_NAME;
 
   53   void setNodeValue(
const node n, tlp::StoredType<double>::ReturnedConstValue v) 
override;
 
   57   class nodeValueRef : 
public AbstractProperty<tlp::DoubleType, tlp::DoubleType,
 
   58                                                tlp::NumericProperty>::nodeValueRef {
 
   64     nodeValueRef &operator=(
 
   65         typename tlp::StoredType<typename DoubleType::RealType>::ReturnedConstValue val) noexcept {
 
   66       _prop->setNodeValue(_n, val);
 
   71     nodeValueRef &operator++() {
 
   72       _prop->setNodeValue(_n, getValue() + 1);
 
   77     auto operator++(
int) {
 
   78       auto val = getValue();
 
   79       _prop->setNodeValue(_n, val + 1);
 
   84     nodeValueRef &operator+=(
double val) {
 
   85       _prop->setNodeValue(_n, getValue() + val);
 
   90     nodeValueRef &operator--() {
 
   91       _prop->setNodeValue(_n, getValue() - 1);
 
   96     auto operator--(
int) {
 
   97       auto val = getValue();
 
   98       _prop->setNodeValue(_n, val - 1);
 
  103     nodeValueRef &operator-=(
double val) {
 
  104       _prop->setNodeValue(_n, getValue() - val);
 
  110   constexpr nodeValueRef operator[](node n) {
 
  111     return nodeValueRef(
this, n);
 
  114   void setEdgeValue(
const edge e, tlp::StoredType<double>::ReturnedConstValue v) 
override;
 
  118   class edgeValueRef : 
public AbstractProperty<tlp::DoubleType, tlp::DoubleType,
 
  119                                                tlp::NumericProperty>::edgeValueRef {
 
  121     constexpr edgeValueRef(DoubleProperty *prop, edge e)
 
  122         : AbstractProperty<
tlp::DoubleType, 
tlp::DoubleType, 
tlp::NumericProperty>::edgeValueRef(
 
  125     edgeValueRef &operator=(
 
  126         typename tlp::StoredType<typename DoubleType::RealType>::ReturnedConstValue val) noexcept {
 
  127       _prop->setEdgeValue(_e, val);
 
  132     edgeValueRef &operator++() {
 
  133       _prop->setEdgeValue(_e, getValue() + 1);
 
  138     auto operator++(
int) {
 
  139       auto val = getValue();
 
  140       _prop->setEdgeValue(_e, val + 1);
 
  145     edgeValueRef &operator+=(
double val) {
 
  146       _prop->setEdgeValue(_e, getValue() + val);
 
  151     edgeValueRef &operator--() {
 
  152       _prop->setEdgeValue(_e, getValue() - 1);
 
  157     auto operator--(
int) {
 
  158       auto val = getValue();
 
  159       _prop->setEdgeValue(_e, val - 1);
 
  164     edgeValueRef &operator-=(
double val) {
 
  165       _prop->setEdgeValue(_e, getValue() - val);
 
  171   constexpr edgeValueRef operator[](edge e) {
 
  172     return edgeValueRef(
this, e);
 
  175   void setAllNodeValue(tlp::StoredType<double>::ReturnedConstValue v) 
override;
 
  177   void setValueToGraphNodes(tlp::StoredType<double>::ReturnedConstValue v,
 
  178                             const Graph *graph) 
override;
 
  179   void setAllEdgeValue(tlp::StoredType<double>::ReturnedConstValue v) 
override;
 
  180   void setValueToGraphEdges(tlp::StoredType<double>::ReturnedConstValue v,
 
  181                             const Graph *graph) 
override;
 
  183   enum StandardMetaValueCalculator : 
unsigned int {
 
  193   void setMetaValueCalculator(StandardMetaValueCalculator nodeCalc = AVG_CALC,
 
  194                               StandardMetaValueCalculator edgeCalc = AVG_CALC);
 
  197   double getNodeDoubleValue(
const node n)
 const override {
 
  198     return getNodeValue(n);
 
  200   double getNodeDoubleDefaultValue()
 const override {
 
  201     return getNodeDefaultValue();
 
  203   double getNodeDoubleMin(
const Graph *g = 
nullptr)
 override {
 
  204     return getNodeMin(g);
 
  206   double getNodeDoubleMax(
const Graph *g = 
nullptr)
 override {
 
  207     return getNodeMax(g);
 
  209   double getEdgeDoubleValue(
const edge e)
 const override {
 
  210     return getEdgeValue(e);
 
  212   double getEdgeDoubleDefaultValue()
 const override {
 
  213     return getEdgeDefaultValue();
 
  215   double getEdgeDoubleMin(
const Graph *g = 
nullptr)
 override {
 
  216     return getEdgeMin(g);
 
  218   double getEdgeDoubleMax(
const Graph *g = 
nullptr)
 override {
 
  219     return getEdgeMax(g);
 
  222   void nodesUniformQuantification(
unsigned int) 
override;
 
  224   void edgesUniformQuantification(
unsigned int) 
override;
 
  226   NumericProperty *copyProperty(Graph *g)
 override {
 
  227     DoubleProperty *newProp = 
new DoubleProperty(g);
 
  235   void treatEvent(
const Event &) 
override;
 
  244     : 
public AbstractVectorProperty<tlp::DoubleVectorType, tlp::DoubleType> {
 
  247       : AbstractVectorProperty<DoubleVectorType, tlp::DoubleType>(g, n) {}
 
  249   using AbstractVectorProperty<tlp::DoubleVectorType, tlp::DoubleType>::operator=;
 
  251   static const std::string propertyTypename;
 
  253     return propertyTypename;
 
  255   DEFINE_GET_CPP_CLASS_NAME;
 
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
 
A graph property that maps a double value to graph elements.
 
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
 
void setMetaValueCalculator(PropertyInterface::MetaValueCalculator *calc) override
Sets the Calculator for meta nodes and edges.
 
PropertyInterface * clonePrototype(Graph *, const std::string &) const override
Creates a property of the same type (e.g. tlp::DoubleProperty) in the graph. The new property will no...
 
A graph property that maps a std::vector<double> value to graph elements.
 
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
 
PropertyInterface * clonePrototype(Graph *, const std::string &) const override
Creates a property of the same type (e.g. tlp::DoubleProperty) in the graph. The new property will no...
 
Abstracts the computation of minimal and maximal values on node and edge values of properties.
 
Interface all numerical properties. Property values are always returned as double.
 
PropertyInterface describes the interface of a graph property.
 
The node struct represents a node in a Graph object.