protected override Dictionary <int, DistanceTableEntry> BuildDistanceTable(int sourceVertex)
        {
            var queue         = new Queue <int>();
            var distanceTable = GetInitialDistanceTable(sourceVertex);

            queue.Enqueue(sourceVertex);

            while (queue.Any())
            {
                var vertex   = queue.Dequeue();
                var distance = distanceTable[vertex].Distance;

                foreach (var adjacentVertex in Graph.AdjacentVertices(vertex))
                {
                    if (distanceTable[adjacentVertex].Distance == null)
                    {
                        distanceTable[adjacentVertex].Distance       = distance + 1;
                        distanceTable[adjacentVertex].PreviousVertex = vertex;

                        if (Graph.AdjacentVertices(adjacentVertex).Any())
                        {
                            queue.Enqueue(adjacentVertex);
                        }
                    }
                }
            }

            return(distanceTable);
        }
        protected override Dictionary <int, DistanceTableEntry> BuildDistanceTable(int sourceVertex)
        {
            var q             = new Queue <int>();
            var distanceTable = GetInitialDistanceTable(sourceVertex);

            var priorityQueue = new PriorityQueue <int>();

            priorityQueue.Enqueue(0, sourceVertex);

            while (priorityQueue.Any)
            {
                var currentVertex = priorityQueue.Dequeue();
                var distance      = distanceTable[currentVertex].Distance;
                foreach (var adjacentVertex in Graph.AdjacentVertices(currentVertex))
                {
                    var newDistanceFromOrigin     = distance + Graph.EdgeWeight(currentVertex, adjacentVertex);
                    var currentDistanceFromOrigin = distanceTable[adjacentVertex].Distance;

                    if (currentDistanceFromOrigin == null || newDistanceFromOrigin < currentDistanceFromOrigin)
                    {
                        distanceTable[adjacentVertex].Distance       = newDistanceFromOrigin;
                        distanceTable[adjacentVertex].PreviousVertex = currentVertex;
                        priorityQueue.Enqueue(newDistanceFromOrigin.Value, adjacentVertex);
                    }
                }
            }

            return(distanceTable);
        }