public class DirectedEdge extends GraphComponentimplements Comparable
PlanarGraph. A DirectedEdge may or may not have a reference to a parent
Edge (some applications of planar graphs may not require explicit Edge objects to be created). Usually a client using a
PlanarGraph will subclass
DirectedEdge to add its own application-specific data and methods.
| Modifier and Type | Field and Description |
|---|---|
protected double |
angle
|
protected boolean |
edgeDirection
|
protected Node |
from
|
protected Coordinate |
p0
|
protected Coordinate |
p1
|
protected Edge |
parentEdge
|
protected int |
quadrant
|
protected DirectedEdge |
sym
|
protected Node |
to
|
isMarked, isVisited| Constructor and Description |
|---|
DirectedEdge(Node
Constructs a DirectedEdge connecting the
from node to the
to node.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareDirection(DirectedEdge
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
|
int |
compareTo(Object
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
|
double |
getAngle()
Returns the angle that the start of this DirectedEdge makes with the positive x-axis, in radians.
|
Coordinate |
getCoordinate()
Returns the coordinate of the from-node.
|
Coordinate |
getDirectionPt()
Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's orientation.
|
Edge |
getEdge()
Returns this DirectedEdge's parent Edge, or null if it has none.
|
boolean |
getEdgeDirection()
Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge.
|
Node |
getFromNode()
Returns the node from which this DirectedEdge leaves.
|
int |
getQuadrant()
Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.
|
DirectedEdge |
getSym()
Returns the symmetric DirectedEdge -- the other DirectedEdge associated with this DirectedEdge's parent Edge.
|
Node |
getToNode()
Returns the node to which this DirectedEdge goes.
|
boolean |
isRemoved()
Tests whether this directed edge has been removed from its containing graph
|
void |
print(PrintStream
Prints a detailed string representation of this DirectedEdge to the given PrintStream.
|
void |
setEdge(Edge
Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).
|
void |
setSym(DirectedEdge
Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.
|
static List |
toEdges(Collection
Returns a List containing the parent Edge (possibly null) for each of the given DirectedEdges.
|
getComponentWithVisitedState, getContext, getData, isMarked, isVisited, setContext, setData, setMarked, setMarked, setVisited, setVisitedprotected EdgeparentEdge
protected Nodefrom
protected Nodeto
protected Coordinatep0
protected Coordinatep1
protected DirectedEdgesym
protected boolean edgeDirection
protected int quadrant
protected double angle
public DirectedEdge(Nodefrom, Node to, Coordinate directionPt, boolean edgeDirection)
from node to the
to node.
directionPt - specifies this DirectedEdge's direction vector (determined by the vector from the
from node to
directionPt)
edgeDirection - whether this DirectedEdge's direction is the same as or opposite to that of the parent Edge (if any)
public static ListtoEdges(Collection dirEdges)
public EdgegetEdge()
public void setEdge(EdgeparentEdge)
public int getQuadrant()
public CoordinategetDirectionPt()
public boolean getEdgeDirection()
public NodegetFromNode()
public NodegetToNode()
public CoordinategetCoordinate()
public double getAngle()
public DirectedEdgegetSym()
public void setSym(DirectedEdgesym)
public boolean isRemoved()
isRemoved in class
GraphComponent
true if this directed edge is removed
public int compareTo(Objectobj)
Using the obvious algorithm of simply computing the angle is not robust, since the angle calculation is susceptible to roundoff. A robust algorithm is:
CGAlgorithms.computeOrientation(Coordinate, Coordinate, Coordinate) function can be used to decide the relative orientation of the vectors. public int compareDirection(DirectedEdgee)
Using the obvious algorithm of simply computing the angle is not robust, since the angle calculation is susceptible to roundoff. A robust algorithm is:
CGAlgorithms.computeOrientation(Coordinate, Coordinate, Coordinate) function can be used to decide the relative orientation of the vectors. public void print(PrintStreamout)