19 #include <tulip/Graph.h>
20 #include <tulip/Coord.h>
22 template<
typename nodeType,
typename edgeType,
typename propType>
24 typename nodeType::RealType NodeMax,
typename edgeType::RealType EdgeMin,
typename edgeType::RealType EdgeMax)
25 :
AbstractProperty<nodeType, edgeType, propType>(graph, name), nodeValueUptodate(false), edgeValueUptodate(false), _nodeMin(NodeMin), _nodeMax(NodeMax), _edgeMin(EdgeMin), _edgeMax(EdgeMax) {
28 template<
typename nodeType,
typename edgeType,
typename propType>
31 graph = this->propType::graph;
34 unsigned int graphID = graph->
getId();
35 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(graphID);
37 if ((it == nodeValueUptodate.end()) || ((*it).second ==
false))
38 computeMinMaxNode(graph);
40 return minNode[graphID];
43 template<
typename nodeType,
typename edgeType,
typename propType>
46 graph = this->propType::graph;
49 unsigned int graphID = graph->
getId();
50 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(graphID);
52 if ((it == nodeValueUptodate.end()) || ((*it).second ==
false))
53 computeMinMaxNode(graph);
55 return maxNode[graphID];
58 template<
typename nodeType,
typename edgeType,
typename propType>
61 graph = this->propType::graph;
64 unsigned int graphID = graph->
getId();
65 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(graphID);
67 if ((it == edgeValueUptodate.end()) || ((*it).second ==
false))
68 computeMinMaxEdge(graph);
70 return minEdge[graphID];
73 template<
typename nodeType,
typename edgeType,
typename propType>
76 graph = this->propType::graph;
79 unsigned int graphID = graph->
getId();
80 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(graphID);
82 if ((it == edgeValueUptodate.end()) || ((*it).second ==
false))
83 computeMinMaxEdge(graph);
85 return maxEdge[graphID];
88 template<
typename nodeType,
typename edgeType,
typename propType>
91 graph = this->propType::graph;
94 typename nodeType::RealType maxN2 = _nodeMin, minN2 = _nodeMax;
96 Iterator<node>* nodeIterator = graph->
getNodes();
98 while (nodeIterator->hasNext()) {
99 node n=nodeIterator->next();
100 typename nodeType::RealType tmp = this->getNodeValue(n);
113 unsigned int sgi = graph->
getId();
119 nodeValueUptodate[sgi]=
true;
120 minNode[sgi] = minN2;
121 maxNode[sgi] = maxN2;
124 template<
typename nodeType,
typename edgeType,
typename propType>
126 typename edgeType::RealType maxE2 = _edgeMin, minE2 = _edgeMax;
128 Iterator<edge>* edgeIterator = graph->getEdges();
130 while (edgeIterator->hasNext()) {
131 edge ite=edgeIterator->next();
132 typename edgeType::RealType tmp = this->getEdgeValue(ite);
143 unsigned int sgi = graph->getId();
149 edgeValueUptodate[sgi]=
true;
154 template<
typename nodeType,
typename edgeType,
typename propType>
156 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.begin();
158 if (it != nodeValueUptodate.end()) {
159 typename nodeType::RealType oldV = this->getNodeValue(n);
161 if (newValue != oldV) {
163 for(; it != nodeValueUptodate.end(); ++it) {
166 if ((*it).second ==
true) {
167 unsigned int gid = (*it).first;
168 typename nodeType::RealType minV = minNode[gid];
169 typename nodeType::RealType maxV = maxNode[gid];
172 if ((newValue < minV) || (newValue > maxV) || (oldV == minV) || (oldV == maxV)) {
173 nodeValueUptodate.clear();
182 template<
typename nodeType,
typename edgeType,
typename propType>
184 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.begin();
186 if (it != edgeValueUptodate.end()) {
187 typename edgeType::RealType oldV = this->getEdgeValue(e);
189 if (newValue != oldV) {
191 for(; it != edgeValueUptodate.end(); ++it) {
194 if ((*it).second ==
true) {
195 unsigned int gid = (*it).first;
196 typename edgeType::RealType minV = minEdge[gid];
197 typename edgeType::RealType maxV = maxEdge[gid];
200 if ((newValue < minV) || (newValue > maxV) || (oldV == minV) || (oldV == maxV)) {
201 edgeValueUptodate.clear();
210 template<
typename nodeType,
typename edgeType,
typename propType>
212 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.begin();
214 if (it != nodeValueUptodate.end()) {
216 for(; it != nodeValueUptodate.end(); ++it) {
217 unsigned int gid = (*it).first;
218 minNode[gid] = maxNode[gid] = newValue;
219 nodeValueUptodate[gid] =
true;
224 template<
typename nodeType,
typename edgeType,
typename propType>
226 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.begin();
228 if (it != edgeValueUptodate.end()) {
230 for(; it != edgeValueUptodate.end(); ++it) {
231 unsigned int gid = (*it).first;
232 minEdge[gid] = maxEdge[gid] = newValue;
233 edgeValueUptodate[gid] =
true;
238 template<
typename nodeType,
typename edgeType,
typename propType>
245 switch(graphEvent->getType()) {
246 case GraphEvent::TLP_ADD_NODE:
247 nodeValueUptodate.
clear();
250 case GraphEvent::TLP_DEL_NODE: {
251 unsigned int sgi = graph->
getId();
252 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(sgi);
254 if (it != nodeValueUptodate.end() && it->second) {
255 typename nodeType::RealType oldV = this->getNodeValue(graphEvent->getNode());
258 if ((oldV == minNode[sgi]) || (oldV == maxNode[sgi]))
259 nodeValueUptodate[sgi] =
false;
265 case GraphEvent::TLP_ADD_EDGE:
266 edgeValueUptodate.clear();
269 case GraphEvent::TLP_DEL_EDGE: {
270 unsigned int sgi = graph->
getId();
271 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(sgi);
273 if (it != edgeValueUptodate.end() && it->second) {
274 typename edgeType::RealType oldV = this->getEdgeValue(graphEvent->getEdge());
277 if ((oldV == minEdge[sgi]) || (oldV == maxEdge[sgi])) {
278 edgeValueUptodate[sgi] =
false;
285 case GraphEvent::TLP_AFTER_ADD_SUBGRAPH:
289 case GraphEvent::TLP_BEFORE_DEL_SUBGRAPH: