public DijkstraShortestWeightedDirectedPathEnumerator( IWeightedDirectedGraph <TVertex, TEdge> graph, TVertex origin, IAdder <TEdge> adder, IComparer <TEdge> comparer ) { Graph = graph; Origin = origin; Adder = adder; Comparer = comparer; Heap = new FibonacciHeap <TEdge, HeapEntry>(comparer); Visited = new Dictionary <TVertex, IMinHeapVertex <TEdge, HeapEntry> >(); Initialize(); }
private void Meld(FibonacciHeap <TKey, TValue> other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (other.Comparer != Comparer) { throw new ArgumentException("Cannot meld heaps using different comparators.", nameof(other)); } if (IsEmpty && other.IsEmpty) { return; } if (IsEmpty) { Min = other.Min; } else if (!other.IsEmpty) { Min.Right.Left = other.Min.Left; other.Min.Left.Right = Min.Right; Min.Right = other.Min; other.Min.Left = Min; if (Comparer.Compare(other.Min.Key, Min.Key) < 0) { Min = other.Min; } } Count += other.Count; other.Clear(); }
public FibonacciHeapVertex(FibonacciHeap <TKey, TValue> heap, TKey key, TValue value) { Heap = heap; Key = key; Value = value; }