This file is indexed.

/usr/include/tulip/cxx/minmaxproperty.cxx is in libtulip-dev 4.4.0dfsg2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 */
#include <tulip/Graph.h>
#include <tulip/Coord.h>

template<typename nodeType, typename edgeType, typename propType>
tlp::MinMaxProperty<nodeType, edgeType, propType>::MinMaxProperty(tlp::Graph* graph, std::string name, typename nodeType::RealType NodeMin,
    typename nodeType::RealType NodeMax, typename edgeType::RealType EdgeMin, typename edgeType::RealType EdgeMax)
  : AbstractProperty<nodeType, edgeType, propType>(graph, name), nodeValueUptodate(false), edgeValueUptodate(false), _nodeMin(NodeMin), _nodeMax(NodeMax), _edgeMin(EdgeMin), _edgeMax(EdgeMax) {
}

template<typename nodeType, typename edgeType, typename propType>
typename nodeType::RealType tlp::MinMaxProperty<nodeType, edgeType, propType>::getNodeMin(tlp::Graph* graph) {
  if(!graph) {
    graph = this->propType::graph;
  }

  unsigned int graphID = graph->getId();
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(graphID);

  if ((it == nodeValueUptodate.end()) || ((*it).second == false))
    computeMinMaxNode(graph);

  return minNode[graphID];
}

template<typename nodeType, typename edgeType, typename propType>
typename nodeType::RealType tlp::MinMaxProperty<nodeType, edgeType, propType>::getNodeMax(tlp::Graph* graph) {
  if(!graph) {
    graph = this->propType::graph;
  }

  unsigned int graphID = graph->getId();
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(graphID);

  if ((it == nodeValueUptodate.end()) || ((*it).second == false))
    computeMinMaxNode(graph);

  return maxNode[graphID];
}

template<typename nodeType, typename edgeType, typename propType>
typename edgeType::RealType tlp::MinMaxProperty<nodeType, edgeType, propType>::getEdgeMin(tlp::Graph* graph) {
  if(!graph) {
    graph = this->propType::graph;
  }

  unsigned int graphID = graph->getId();
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(graphID);

  if ((it == edgeValueUptodate.end()) || ((*it).second == false))
    computeMinMaxEdge(graph);

  return minEdge[graphID];
}

template<typename nodeType, typename edgeType, typename propType>
typename edgeType::RealType tlp::MinMaxProperty<nodeType, edgeType, propType>::getEdgeMax(tlp::Graph* graph) {
  if(!graph) {
    graph = this->propType::graph;
  }

  unsigned int graphID = graph->getId();
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(graphID);

  if ((it == edgeValueUptodate.end()) || ((*it).second == false))
    computeMinMaxEdge(graph);

  return maxEdge[graphID];
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::computeMinMaxNode(Graph* graph) {
  if(!graph) {
    graph = this->propType::graph;
  }

  typename nodeType::RealType maxN2 = _nodeMin, minN2 = _nodeMax;

  Iterator<node>* nodeIterator = graph->getNodes();

  while (nodeIterator->hasNext()) {
    node n=nodeIterator->next();
    typename nodeType::RealType tmp = this->getNodeValue(n);

    if (tmp > maxN2) {
      maxN2 = tmp;
    }

    if (tmp < minN2) {
      minN2 = tmp;
    }
  }

  delete nodeIterator;

  unsigned int sgi = graph->getId();

  // be careful to empty graph
  if (maxN2 < minN2)
    minN2 = maxN2;

  nodeValueUptodate[sgi]=true;
  minNode[sgi] = minN2;
  maxNode[sgi] = maxN2;
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::computeMinMaxEdge(Graph* graph) {
  typename edgeType::RealType maxE2 = _edgeMin, minE2 = _edgeMax;

  Iterator<edge>* edgeIterator = graph->getEdges();

  while (edgeIterator->hasNext()) {
    edge ite=edgeIterator->next();
    typename edgeType::RealType tmp = this->getEdgeValue(ite);

    if (tmp>maxE2)
      maxE2 = tmp;

    if (tmp<minE2)
      minE2 = tmp;
  }

  delete edgeIterator;

  unsigned int sgi = graph->getId();

  // be careful to no edges graph
  if (maxE2 < minE2)
    minE2 = maxE2;

  edgeValueUptodate[sgi]=true;
  minEdge[sgi]=minE2;
  maxEdge[sgi]=maxE2;
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::updateNodeValue(tlp::node n, typename nodeType::RealType newValue) {
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.begin();

  if (it != nodeValueUptodate.end()) {
    typename nodeType::RealType oldV = this->getNodeValue(n);

    if (newValue != oldV) {
      // loop on subgraph min/max
      for(; it != nodeValueUptodate.end(); ++it) {
        // if min/max is ok for the current subgraph
        // check if min or max has to be updated
        if ((*it).second == true) {
          unsigned int gid = (*it).first;
          typename nodeType::RealType minV = minNode[gid];
          typename nodeType::RealType maxV = maxNode[gid];

          // check if min or max has to be updated
          if ((newValue < minV) || (newValue > maxV) || (oldV == minV) || (oldV == maxV)) {
            nodeValueUptodate.clear();
            break;
          }
        }
      }
    }
  }
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::updateEdgeValue(tlp::edge e, typename edgeType::RealType newValue) {
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.begin();

  if (it != edgeValueUptodate.end()) {
    typename edgeType::RealType oldV = this->getEdgeValue(e);

    if (newValue != oldV) {
      // loop on subgraph min/max
      for(; it != edgeValueUptodate.end(); ++it) {
        // if min/max is ok for the current subgraph
        // check if min or max has to be updated
        if ((*it).second == true) {
          unsigned int gid = (*it).first;
          typename edgeType::RealType minV = minEdge[gid];
          typename edgeType::RealType maxV = maxEdge[gid];

          // check if min or max has to be updated
          if ((newValue < minV) || (newValue > maxV) || (oldV == minV) || (oldV == maxV)) {
            edgeValueUptodate.clear();
            break;
          }
        }
      }
    }
  }
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::updateAllNodesValues(typename nodeType::RealType newValue) {
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.begin();

  if (it != nodeValueUptodate.end()) {
    // loop on subgraph min/max
    for(; it != nodeValueUptodate.end(); ++it) {
      unsigned int gid = (*it).first;
      minNode[gid] = maxNode[gid] = newValue;
      nodeValueUptodate[gid] = true;
    }
  }
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::updateAllEdgesValues(typename edgeType::RealType newValue) {
  TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.begin();

  if (it != edgeValueUptodate.end()) {
    // loop on subgraph min/max
    for(; it != edgeValueUptodate.end(); ++it) {
      unsigned int gid = (*it).first;
      minEdge[gid] = maxEdge[gid] = newValue;
      edgeValueUptodate[gid] = true;
    }
  }
}

template<typename nodeType, typename edgeType, typename propType>
void tlp::MinMaxProperty<nodeType, edgeType, propType>::treatEvent(const tlp::Event& ev) {
  const GraphEvent* graphEvent = dynamic_cast<const tlp::GraphEvent*>(&ev);

  if (graphEvent) {
    tlp::Graph* graph = graphEvent->getGraph();

    switch(graphEvent->getType()) {
    case GraphEvent::TLP_ADD_NODE:
      nodeValueUptodate.clear();
      break;

    case GraphEvent::TLP_DEL_NODE: {
      unsigned int sgi = graph->getId();
      TLP_HASH_MAP<unsigned int, bool>::const_iterator it = nodeValueUptodate.find(sgi);

      if (it != nodeValueUptodate.end() && it->second) {
        typename nodeType::RealType oldV = this->getNodeValue(graphEvent->getNode());

        // check if min or max has to be updated
        if ((oldV == minNode[sgi]) || (oldV == maxNode[sgi]))
          nodeValueUptodate[sgi] = false;
      }

      break;
    }

    case GraphEvent::TLP_ADD_EDGE:
      edgeValueUptodate.clear();
      break;

    case GraphEvent::TLP_DEL_EDGE: {
      unsigned int sgi = graph->getId();
      TLP_HASH_MAP<unsigned int, bool>::const_iterator it = edgeValueUptodate.find(sgi);

      if (it != edgeValueUptodate.end() && it->second) {
        typename edgeType::RealType oldV = this->getEdgeValue(graphEvent->getEdge());

        // check if min or max has to be updated
        if ((oldV == minEdge[sgi]) || (oldV == maxEdge[sgi])) {
          edgeValueUptodate[sgi] = false;
        }
      }

      break;
    }

    case GraphEvent::TLP_AFTER_ADD_SUBGRAPH:
      graphEvent->getSubGraph()->addListener(this);
      break;

    case GraphEvent::TLP_BEFORE_DEL_SUBGRAPH:
      graphEvent->getSubGraph()->removeListener(this);
      break;

    default:
      // we don't care about the rest
      break;
    }
  }
}