Exemple #1
0
//find (for use with incoming edges heuristic)
Vertex *DenseGraph::find(int val) {
  Vertex v = Vertex(val);
  Vertex *vert = &v;
  if(WRITE_GARBAGE) {
    const char* fn = "garbage";
    std::ofstream garbage(fn);
    garbage << val << std::endl;
    garbage.close();
    remove(fn);
  }
  //DEBUG
  int minIndex = -1;
  double minWeight = DBL_MAX;
  for(int i = 0; i < numEdges; i++) {
    if((edges[i].end == val) && (edges[i].weight < minWeight)) {
      minIndex = i;
      minWeight = edges[i].weight;
    }
  }
  if(minIndex != -1) {
    Edge minEdge(edges[minIndex].start, edges[minIndex].end, edges[minIndex].weight);
    vert->addInEdge(minEdge);
  }
  return vert;
}