19 #include <tulip/Graph.h>
20 #include <tulip/Coord.h>
22 template<
typename nodeType,
typename edgeType>
24 typename nodeType::RealType NodeMax,
typename edgeType::RealType EdgeMin,
typename edgeType::RealType EdgeMax)
25 :
AbstractProperty<nodeType, edgeType>(graph, name), nodeValueUptodate(false), edgeValueUptodate(false), _nodeMin(NodeMin), _nodeMax(NodeMax), _edgeMin(EdgeMin), _edgeMax(EdgeMax) {
28 template<
typename nodeType,
typename edgeType>
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>
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>
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>
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>
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();
115 nodeValueUptodate[sgi]=
true;
116 minNode[sgi] = minN2;
117 maxNode[sgi] = maxN2;
120 template<
typename nodeType,
typename edgeType>
122 typename edgeType::RealType maxE2 = _edgeMin, minE2 = _edgeMax;
124 Iterator<edge>* edgeIterator = graph->getEdges();
126 while (edgeIterator->hasNext()) {
127 edge ite=edgeIterator->next();
128 typename edgeType::RealType tmp = this->getEdgeValue(ite);
139 unsigned int sgi = graph->getId();
141 edgeValueUptodate[sgi]=
true;
146 template<
typename nodeType,
typename edgeType>
148 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.begin();
150 if (it != nodeValueUptodate.end()) {
151 typename nodeType::RealType oldV = this->getNodeValue(n);
153 if (newValue != oldV) {
155 for(; it != nodeValueUptodate.end(); ++it) {
158 if ((*it).second ==
true) {
159 unsigned int gid = (*it).first;
160 typename nodeType::RealType minV = minNode[gid];
161 typename nodeType::RealType maxV = maxNode[gid];
164 if ((newValue < minV) || (newValue > maxV) || (oldV == minV) || (oldV == maxV)) {
165 nodeValueUptodate.clear();
174 template<
typename nodeType,
typename edgeType>
176 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.begin();
178 if (it != edgeValueUptodate.end()) {
179 typename edgeType::RealType oldV = this->getEdgeValue(e);
181 if (newValue != oldV) {
183 for(; it != edgeValueUptodate.end(); ++it) {
186 if ((*it).second ==
true) {
187 unsigned int gid = (*it).first;
188 typename edgeType::RealType minV = minEdge[gid];
189 typename edgeType::RealType maxV = maxEdge[gid];
192 if ((newValue < minV) || (newValue > maxV) || (oldV == minV) || (oldV == maxV)) {
193 edgeValueUptodate.clear();
202 template<
typename nodeType,
typename edgeType>
204 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.begin();
206 if (it != nodeValueUptodate.end()) {
208 for(; it != nodeValueUptodate.end(); ++it) {
209 unsigned int gid = (*it).first;
210 minNode[gid] = maxNode[gid] = newValue;
211 nodeValueUptodate[gid] =
true;
216 template<
typename nodeType,
typename edgeType>
218 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.begin();
220 if (it != edgeValueUptodate.end()) {
222 for(; it != edgeValueUptodate.end(); ++it) {
223 unsigned int gid = (*it).first;
224 minEdge[gid] = maxEdge[gid] = newValue;
225 edgeValueUptodate[gid] =
true;
230 template<
typename nodeType,
typename edgeType>
237 switch(graphEvent->getType()) {
238 case GraphEvent::TLP_ADD_NODE:
239 nodeValueUptodate.
clear();
242 case GraphEvent::TLP_DEL_NODE: {
243 unsigned int sgi = graph->
getId();
244 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(sgi);
246 if (it != nodeValueUptodate.end() && it->second) {
247 typename nodeType::RealType oldV = this->getNodeValue(graphEvent->getNode());
250 if ((oldV == minNode[sgi]) || (oldV == maxNode[sgi]))
251 nodeValueUptodate[sgi] =
false;
257 case GraphEvent::TLP_ADD_EDGE:
258 edgeValueUptodate.clear();
261 case GraphEvent::TLP_DEL_EDGE: {
262 unsigned int sgi = graph->
getId();
263 TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(sgi);
265 if (it != edgeValueUptodate.end() && it->second) {
266 typename edgeType::RealType oldV = this->getEdgeValue(graphEvent->getEdge());
269 if ((oldV == minEdge[sgi]) || (oldV == maxEdge[sgi])) {
270 edgeValueUptodate[sgi] =
false;
277 case GraphEvent::TLP_AFTER_ADD_SUBGRAPH:
281 case GraphEvent::TLP_BEFORE_DEL_SUBGRAPH: