Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/20/12 17:32:19 (12 years ago)
Author:
spimming
Message:

#1894:
Dijkstra: get node with a specific rank
graph interface extended: get vertices
fixed bug in ReadData method
methods to perform routing algorithm benchmark added to test program

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/DijkstraAlgorithmV2.cs

    r8481 r8509  
    5353
    5454    #endregion
     55
     56    public long GetNodeIdWithRank(long sourceNodeId, int rank) {
     57      visitedNodes = new HashSet<long>();        // visited
     58      unvisitedNodes = new HashSet<long>();      // unvisited
     59      distances = new Dictionary<long, float>();
     60      predecessors = new Dictionary<long, long>();
     61      int currentRank = 0;
     62
     63
     64      long currentNode = sourceNodeId;
     65      distances.Add(currentNode, 0);
     66      unvisitedNodes.Add(currentNode);
     67
     68      while (unvisitedNodes.Count > 0) {
     69        currentNode = GetMinimumDistance(unvisitedNodes);
     70        visitedNodes.Add(currentNode);
     71        unvisitedNodes.Remove(currentNode);
     72        currentRank++;
     73        if (currentRank == rank) {
     74          break;
     75        }
     76        FindMinimalWeight(currentNode);
     77      }
     78      return currentNode;
     79    }
    5580
    5681    private long GetMinimumDistance(HashSet<long> nodeIds) {
Note: See TracChangeset for help on using the changeset viewer.