The Tulip property enables to store attribute on the elements of a graph. In Tulip we call it Property in order to prevent confusion with the graph attribute. Thus, the properties are for the elements and attributes are for the graphs. The main idea in Tulip is that a property is always define for all kind (node and edge) of elements in the graph. Thus we can always query for an edge or node property associated value.
As for the graph structure, to access the value of an elements one must query a property. This characteristic makes the use of the library a little bit less intuitive but, it enables to store efficiently the properties.
In general properties can be seen as an associative table where you can set or get the value of an element. In order to prevent having a lot of cast in the code all the properties have type and thus there is no need to cast your result when you query a property. The standard operations of a property are given below :
List of available modification operations
void setNodeValue(node,TYPE)
: set the value of a node.
void setAllNodeValue(TYPE)
: set the value of all nodes.
void setEdgeValue(edge,TYPE)
: set the value of an edge.
void setAllEdgeValue(TYPE)
: set the value of all edges.
List of available access operations
TYPE getNodeValue(node)
: return the value of a node.
TYPE getEdgeValue(edge)
: return the value of an edge.
For each kind of properties it exists a specific implementation (inheritance) that enables to obtain
specific operations (see developer documentation) depending of the Type. For instance, it is possible to obtain
the maximum value of a property if the property type is double
.
One of the most important things is to know how to create a property or to access to an existing property
in the graph. To do this a graph includes a set of functions that enables to obtain/create/delete a Property. Because
the C++ signature of function does not include the TYPE of the returned argument, the syntax for this call is not
very simple. For instance, if one wants to obtain a property containing double (called MetricProxy in Tulip) one must use
the following syntax : MetricProxy *metric=graph->getProperty<MetricProxy>("name of the property");
In the graph each property is identified by its name which a std::string, when one asks for a property the type of this
property is checked using the run time type interrogation mechanism of the C++. Warning, this test is only done when one
compiles its sources in DEBUG mode (default mode). In order to facilitate the navigation/edition of the set of properties, a
set of function is accessible through the graph interface.
List of available operations
Iterators * getLocalProperties()
: return an iterator on all existing properties.
void delLocalProperty(std::string)
: delete a property.
bool existLocalProperty(std::string)
: return true if the property exists.
Proxytype * getLocalProperty (std::string)
: return the property or if it does not exist create
a new one and return it
The mechanism described above works well for graphs. However, in Tulip we are working with a hierarchy of graphs. Thus a special mechanism have been added in order to share easily properties between graphs. This mechanism use the fact that if a property exists in an ancestor of a graph, it can be use on the graph. This looks like an inheritance mechanism of properties between graphs. As in object oriented language, in Tulip, it is possible to inherit a property or to have it defined locally. In order to facilitate the navigation/edition of the set of properties, a set of function is accessible through the graph interface.
List of available operations
Iterators * getInheritedProperties()
: return an iterator on all the inherited properties.
bool existProperty(std::string)
: return true if the property exists (inherited or locally).
Proxytype * getProperty(std::string)
: return the property (inherited or local) or if it does not exist create
a new one (locally) and return it