Пример #1
0
        /**
         * Returns the edges making up the path. The first edge in this path is incident to the start
         * vertex. The last edge is incident to the end vertex. The vertices along the path can be
         * obtained by traversing from the start vertex, finding its opposite across the first edge, and
         * then doing the same successively across subsequent edges; see {@link #getVertexList()}.
         *
         * <p>
         * Whether or not the returned edge list is modifiable depends on the path implementation.
         *
         * @return list of edges traversed by the path
         */
        public virtual List <E> getEdgeList()
        {
            List <V> vertexList = this.getVertexList();

            if (vertexList.Count < 2)
            {
                return(new List <E>());
            }

            Graph <V, E> g              = this.getGraph();
            List <E>     edgeList       = new List <E>();
            var          vertexIterator = vertexList.GetEnumerator();

            vertexIterator.MoveNext();
            V u = vertexIterator.Current;

            while (vertexIterator.MoveNext())
            {
                V v = vertexIterator.Current;
                edgeList.Add(g.getEdge(u, v));
                u = v;
            }
            return(edgeList);
        }