Package org.locationtech.jts.planargraph
Class PlanarGraph
java.lang.Object
org.locationtech.jts.planargraph.PlanarGraph
- Direct Known Subclasses:
LineMergeGraph
,PolygonizeGraph
Represents a directed graph which is embeddable in a planar surface.
This class and the other classes in this package serve as a framework for
building planar graphs for specific algorithms. This class must be
subclassed to expose appropriate methods to construct the graph. This allows
controlling the types of graph components (DirectedEdge
s,
Edge
s and Node
s) which can be added to the graph. An
application which uses the graph framework will almost always provide
subclasses for one or more graph components, which hold application-specific
data and graph algorithms.
- Version:
- 1.7
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(DirectedEdge dirEdge) Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges, to ensure the edges added are of the right class.protected void
Adds the Edge and its DirectedEdges with this PlanarGraph.protected void
Adds a node to the map, replacing any that is already at that location.boolean
contains
(DirectedEdge de) Tests whether this graph contains the givenDirectedEdge
boolean
Tests whether this graph contains the givenEdge
Returns an Iterator over the DirectedEdges in this PlanarGraph, in the order in which they were added.Returns an Iterator over the Edges in this PlanarGraph, in the order in which they were added.findNode
(Coordinate pt) findNodesOfDegree
(int degree) Returns all Nodes with the given number of Edges around it.getEdges()
Returns the Edges that have been added to this PlanarGraphgetNodes()
Returns an Iterator over the Nodes in this PlanarGraph.void
remove
(DirectedEdge de) Removes aDirectedEdge
from its from-Node
and from this graph.void
Removes anEdge
and its associatedDirectedEdge
s from their from-Nodes and from the graph.void
Removes a node from the graph, along with any associated DirectedEdges and Edges.
-
Field Details
-
edges
-
dirEdges
-
nodeMap
-
-
Constructor Details
-
PlanarGraph
public PlanarGraph()Constructs a empty graph.
-
-
Method Details
-
findNode
- Parameters:
pt
- the location to query- Returns:
- the node found
or
null
if this graph contains no node at the location
-
add
Adds a node to the map, replacing any that is already at that location. Only subclasses can add Nodes, to ensure Nodes are of the right type.- Parameters:
node
- the node to add
-
add
Adds the Edge and its DirectedEdges with this PlanarGraph. Assumes that the Edge has already been created with its associated DirectEdges. Only subclasses can add Edges, to ensure the edges added are of the right class. -
add
Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges, to ensure the edges added are of the right class. -
nodeIterator
Returns an Iterator over the Nodes in this PlanarGraph. -
contains
Tests whether this graph contains the givenEdge
- Parameters:
e
- the edge to query- Returns:
true
if the graph contains the edge
-
contains
Tests whether this graph contains the givenDirectedEdge
- Parameters:
de
- the directed edge to query- Returns:
true
if the graph contains the directed edge
-
getNodes
-
dirEdgeIterator
Returns an Iterator over the DirectedEdges in this PlanarGraph, in the order in which they were added.- See Also:
-
edgeIterator
Returns an Iterator over the Edges in this PlanarGraph, in the order in which they were added.- See Also:
-
getEdges
Returns the Edges that have been added to this PlanarGraph- See Also:
-
remove
-
remove
Removes aDirectedEdge
from its from-Node
and from this graph. This method does not remove theNode
s associated with the DirectedEdge, even if the removal of the DirectedEdge reduces the degree of a Node to zero. -
remove
Removes a node from the graph, along with any associated DirectedEdges and Edges. -
findNodesOfDegree
Returns all Nodes with the given number of Edges around it.
-