Esempio n. 1
0
        private void Visit(EdgeWeightedGraph graph, Int32 sourceVertice)
        {
            this._visited[sourceVertice] = true;

            foreach (Edge edge in graph.GetAdjacentVertices(sourceVertice))
            {
                Int32 targetVertice = edge.Other(sourceVertice);

                if (this._visited[targetVertice])
                {
                    continue; // v-w is an obsolete edge.
                }
                if (edge.Weight < this._distTo[targetVertice])
                {
                    this._distTo[targetVertice] = edge.Weight;
                    this._edgeTo[targetVertice] = edge;

                    if (this._crossingEdgesByWeight.Contains(targetVertice))
                    {
                        this._crossingEdgesByWeight.DecreaseItem(targetVertice, this._distTo[targetVertice]);
                    }
                    else
                    {
                        this._crossingEdgesByWeight.Add(targetVertice, this._distTo[targetVertice]);
                    }
                }
            }
        }
Esempio n. 2
0
        private void Visit(EdgeWeightedGraph graph, Int32 vertice)
        {
            // Mark vertice and add to pq all edges from vertice to unmarked vertices.
            this._visited[vertice] = true;

            foreach (Edge edge in graph.GetAdjacentVertices(vertice))
            {
                if (!this._visited[edge.Other(vertice)])
                {
                    this._crossingEdgesByWeight.Add(edge);
                }
            }
        }