Package org.geotools.graph.path
Class Walk
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Node>,Collection<Node>,List<Node>,RandomAccess,NodeSequence
Represents a walk in a graph. A walk W is defined as an ordered set of nodes that two adjacenct nodes in the
set share an edge. More precisley:
G = {N,E} W = { n(i) in N | (n(i-1),n(i)) in E }
G = {N,E} W = { n(i) in N | (n(i-1),n(i)) in E }
- Author:
- Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
- See Also:
-
Field Summary
Fields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanAdds a node to the walk.booleanaddAll(int index, Collection<? extends Node> c) booleanaddAll(Collection<? extends Node> c) booleanvoidaddEdges(Collection<Edge> edges) Internal method for building the edge set of the walk.booleanbooleangetEdges()Calculates the edges in the walk.getFirst()Returns the first node in the sequence.getLast()Returns the last node in the sequence.inthashCode()booleanisClosed()Determines if the walk is closed.booleanisValid()A valid walk is one in which each pair of adjacent nodes in the sequence share an edge.remove(int index) booleanvoidRemoves a node from the walk.booleanvoidreverse()Reverses the path.Returns an iterator that iterates over the path in reverse.voidtruncate(int index) Truncates the path at the specified index.Methods inherited from class ArrayList
clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAll, toStringMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
containsAllMethods inherited from interface NodeSequence
iterator, size
-
Constructor Details
-
Walk
public Walk() -
Walk
-
-
Method Details
-
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:
isValidin interfaceNodeSequence- Returns:
- True if valid, otherwise false.
-
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.- Returns:
- The edges of the walk, otherwise null if the edges cannot be calculated.
-
add
Adds a node to the walk. Adding a node clears the edge list which will be recalculated on the next call to getEdges(). -
add
-
addAll
-
addAll
-
addEdge
-
addEdges
-
remove
Removes a node from the walk. Removing a node clears the edge list which will be recalculated on the next call to getEdges().- Parameters:
node- Node to remove from the walk.
-
remove
-
remove
-
removeAll
-
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.- Returns:
- True if closed, otherwise false.
-
getFirst
Description copied from interface:NodeSequenceReturns the first node in the sequence.- Specified by:
getFirstin interfaceNodeSequence- Returns:
- Object of tupe Node.
- See Also:
-
getLast
Description copied from interface:NodeSequenceReturns the last node in the sequence.- Specified by:
getLastin interfaceNodeSequence- Returns:
- Object of type node.
- See Also:
-
buildEdges
Internal method for building the edge set of the walk. This method calculated the edges upon every call.- Returns:
- 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.- Parameters:
index- The index of first node to be removed.
-
riterator
Returns an iterator that iterates over the path in reverse. The iterator does not support the remove operation.- Returns:
- the reverse iterator.
-
duplicate
-
equals
-
equals
-
hashCode
public int hashCode()
-