Class Walk

    • Constructor Detail

      • Walk

        public Walk()
    • Method Detail

      • isValid

        public boolean isValid()
        A valid walk is one in which each pair of adjacent nodes in the sequence share an edge. Note,
        Specified by:
        isValid in interface NodeSequence
        True if valid, otherwise false.
      • getEdges

        public List<Edge> getEdges()
        Calculates the edges in the walk. If the edges of the walk cannot be calculated (due to an invalid walk), null is returned, otherwise the list of edges is returned.
        The edges of the walk, otherwise null if the edges cannot be calculated.
      • add

        public boolean add​(Node node)
        Adds a node to the walk. Adding a node clears the edge list which will be recalculated on the next call to getEdges().
        Specified by:
        add in interface Collection<Node>
        Specified by:
        add in interface List<Node>
        add in class ArrayList<Node>
        node - Node to add to the walk.
      • addEdge

        public boolean addEdge​(Edge e)
      • remove

        public void remove​(Node node)
        Removes a node from the walk. Removing a node clears the edge list which will be recalculated on the next call to getEdges().
        node - Node to remove from the walk.
      • isClosed

        public boolean isClosed()
        Determines if the walk is closed. A closed walk is one in which the first and last nodes are the same.
        True if closed, otherwise false.
      • buildEdges

        protected List<Edge> buildEdges()
        Internal method for building the edge set of the walk. This method calculated the edges upon every call.
        The list of edges for the walk, or null if the edge set could not be calculated due to an invalid walk.
      • reverse

        public void reverse()
        Reverses the path.
      • truncate

        public void truncate​(int index)
        Truncates the path at the specified index. Nodes in the path whose index is >= the specified index are removed.
        index - The index of first node to be removed.
      • riterator

        public Iterator<Node> riterator()
        Returns an iterator that iterates over the path in reverse. The iterator does not support the remove operation.
        the reverse iterator.
      • duplicate

        public Path duplicate()
      • equals

        public boolean equals​(Walk other)