Class GraphComponent
java.lang.Object
org.locationtech.jts.planargraph.GraphComponent
- Direct Known Subclasses:
DirectedEdge, Edge, Node
The base class for all graph component classes.
Maintains flags of use in generic graph algorithms.
Provides two flags:
- marked - typically this is used to indicate a state that persists for the course of the graph's lifetime. For instance, it can be used to indicate that a component has been logically deleted from the graph.
- visited - this is used to indicate that a component has been processed or visited by an single graph algorithm. For instance, a breadth-first traversal of the graph might use this to indicate that a node has already been traversed. The visited flag may be set and cleared many times during the lifetime of a graph.
Graph components support storing user context data. This will typically be used by client algorithms which use planar graphs.
- Version:
- 1.7
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GraphComponentgetComponentWithVisitedState(Iterator i, boolean visitedState) Finds the firstGraphComponentin aIteratorset which has the specified visited state.Gets the user-defined data for this component.getData()Gets the user-defined data for this component.booleanisMarked()Tests if a component has been marked at some point during the processing involving this graph.abstract booleanTests whether this component has been removed from its containing graphbooleanTests if a component has been visited during the course of a graph algorithmvoidsetContext(Object data) Sets the user-defined data for this component.voidSets the user-defined data for this component.voidsetMarked(boolean isMarked) Sets the marked flag for this component.static voidSets the Marked state for allGraphComponents in anIteratorvoidsetVisited(boolean isVisited) Sets the visited flag for this component.static voidsetVisited(Iterator i, boolean visited) Sets the Visited state for allGraphComponents in anIterator
-
Field Details
-
isMarked
protected boolean isMarked -
isVisited
protected boolean isVisited
-
-
Constructor Details
-
GraphComponent
public GraphComponent()
-
-
Method Details
-
setVisited
Sets the Visited state for allGraphComponents in anIterator- Parameters:
i- the Iterator to scanvisited- the state to set the visited flag to
-
setMarked
Sets the Marked state for allGraphComponents in anIterator- Parameters:
i- the Iterator to scanmarked- the state to set the Marked flag to
-
getComponentWithVisitedState
Finds the firstGraphComponentin aIteratorset which has the specified visited state.- Parameters:
i- an Iterator of GraphComponentsvisitedState- the visited state to test- Returns:
- the first component found, or
nullif none found
-
isVisited
public boolean isVisited()Tests if a component has been visited during the course of a graph algorithm- Returns:
trueif the component has been visited
-
setVisited
public void setVisited(boolean isVisited) Sets the visited flag for this component.- Parameters:
isVisited- the desired value of the visited flag
-
isMarked
public boolean isMarked()Tests if a component has been marked at some point during the processing involving this graph.- Returns:
trueif the component has been marked
-
setMarked
public void setMarked(boolean isMarked) Sets the marked flag for this component.- Parameters:
isMarked- the desired value of the marked flag
-
setContext
Sets the user-defined data for this component.- Parameters:
data- an Object containing user-defined data
-
getContext
Gets the user-defined data for this component.- Returns:
- the user-defined data
-
setData
Sets the user-defined data for this component.- Parameters:
data- an Object containing user-defined data
-
getData
Gets the user-defined data for this component.- Returns:
- the user-defined data
-
isRemoved
public abstract boolean isRemoved()Tests whether this component has been removed from its containing graph- Returns:
trueif this component is removed
-