- Timestamp:
- 09/13/12 10:34:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/PriorityQueues/FibonacciHeap.cs
r8572 r8640 47 47 min = n; 48 48 } else { 49 // concateneate the root list (becoming left sibling of root) 49 50 n.Right = min; 50 51 n.Left = min.Left; 51 52 n.Right.Left = n; 52 53 n.Left.Right = n; 54 // update point of minimum if necessary 53 55 if (n.Key.CompareTo(min.Key) < 0) { 54 56 min = n; … … 103 105 104 106 private void Link(HeapNode y, HeapNode z) { 107 // remove y from the root list 105 108 y.Left.Right = y.Right; 106 109 y.Right.Left = y.Left; 107 110 111 // make y a child of x, ... 108 112 y.Parent = z; 109 113 if (z.Child == null) { … … 117 121 y.Right.Left = y; 118 122 } 123 124 // ... incrementing degree[x] 119 125 z.Degree++; 120 126 y.Mark = false; … … 122 128 123 129 private void Consolidate() { 124 //TODO: explain magic number125 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 126 132 HeapNode start = min; 127 133 HeapNode w = min; 128 134 135 // for each node w in the root list 129 136 do { 130 137 HeapNode x = w; … … 157 164 min = null; 158 165 159 for (int i = 0; i < 45; i++) { 166 // find the new minimum key 167 for (int i = 0; i < dn; i++) { 160 168 if (A[i] != null) { 161 169 HeapNode n = A[i];
Note: See TracChangeset
for help on using the changeset viewer.