Exemplo n.º 1
0
        private void  createEdgeList(ClosestFirstIterator iter, System.Object endVertex)
        {
            m_edgeList = new System.Collections.ArrayList();

            while (true)
            {
                Edge edge = iter.getSpanningTreeEdge(endVertex);

                if (edge == null)
                {
                    break;
                }

                m_edgeList.Add(edge);
                endVertex = edge.oppositeVertex(endVertex);
            }

            ((ArrayList)m_edgeList).Reverse();
        }
Exemplo n.º 2
0
        /// <summary> Creates and executes a new DijkstraShortestPath algorithm instance. An
        /// instance is only good for a single search; after construction, it can
        /// be accessed to retrieve information about the path found.
        ///
        /// </summary>
        /// <param name="graph">the graph to be searched
        /// </param>
        /// <param name="startVertex">the vertex at which the path should start
        /// </param>
        /// <param name="endVertex">the vertex at which the path should end
        /// </param>
        /// <param name="radius">limit on path length, or Double.POSITIVE_INFINITY for
        /// unbounded search
        /// </param>
        public DijkstraShortestPath(Graph graph, System.Object startVertex, System.Object endVertex, double radius)
        {
            ClosestFirstIterator iter = new ClosestFirstIterator(graph, startVertex, radius);

            //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
            while (iter.MoveNext())
            {
                //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                System.Object vertex = iter.Current;

                if (vertex.Equals(endVertex))
                {
                    createEdgeList(iter, endVertex);
                    m_pathLength = iter.getShortestPathLength(endVertex);

                    return;
                }
            }

            m_edgeList   = null;
            m_pathLength = System.Double.PositiveInfinity;
        }