Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/13/12 10:34:51 (12 years ago)
Author:
spimming
Message:

#1894:

  • Included costCalculator in a star search
  • restructured and renamed Dijkstra algorithm
  • Added code comments to FibonacciHeap
File:
1 edited

Legend:

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

    r8572 r8640  
    4747        min = n;
    4848      } else {
     49        // concateneate the root list (becoming left sibling of root)
    4950        n.Right = min;
    5051        n.Left = min.Left;
    5152        n.Right.Left = n;
    5253        n.Left.Right = n;
     54        // update point of minimum if necessary
    5355        if (n.Key.CompareTo(min.Key) < 0) {
    5456          min = n;
     
    103105
    104106    private void Link(HeapNode y, HeapNode z) {
     107      // remove y from the root list
    105108      y.Left.Right = y.Right;
    106109      y.Right.Left = y.Left;
    107110
     111      // make y a child of x, ...
    108112      y.Parent = z;
    109113      if (z.Child == null) {
     
    117121        y.Right.Left = y;
    118122      }
     123
     124      // ... incrementing degree[x]
    119125      z.Degree++;
    120126      y.Mark = false;
     
    122128
    123129    private void Consolidate() {
    124       //TODO: explain magic number
    125       HeapNode[] A = new HeapNode[45];
     130      int dn = (int)Math.Floor(Math.Log(size) / Math.Log(2)) + 1; // log2size[Heap]
     131      HeapNode[] A = new HeapNode[dn];  // consolidation array
    126132      HeapNode start = min;
    127133      HeapNode w = min;
    128134
     135      // for each node w in the root list
    129136      do {
    130137        HeapNode x = w;
     
    157164      min = null;
    158165
    159       for (int i = 0; i < 45; i++) {
     166      // find the new minimum key
     167      for (int i = 0; i < dn; i++) {
    160168        if (A[i] != null) {
    161169          HeapNode n = A[i];
Note: See TracChangeset for help on using the changeset viewer.