jdsl.map.ref
Class TripartiteEmbeddedPlanarGraph

java.lang.Object
  |
  +--jdsl.core.ref.AbstractPositionalContainer
        |
        +--jdsl.graph.ref.AbstractGraph
              |
              +--jdsl.map.ref.TripartiteEmbeddedPlanarGraph
All Implemented Interfaces:
Container, EmbeddedPlanarGraph, InspectableContainer, InspectableEmbeddedPlanarGraph, InspectableGraph, InspectablePositionalContainer, ModifiableGraph, PositionalContainer

public class TripartiteEmbeddedPlanarGraph
extends AbstractGraph
implements EmbeddedPlanarGraph

An implementation of an EmbeddedPlanarGraph via a tripartite OrderedGraph. The vertices of the OrderedGraph represent vertices, edges, and faces of the EmbeddedPlanarGraph. The edges of the OrderedGraph represent the incidence relationship between edges and vertices, and between edges and faces in the EmbeddedPlanarGraph. Each vertex of the OrderedGraph representing an edge of the EmbeddedPlanarGraph has four adjacent vertices: two representing vertices and two representing faces of the EmbeddedPlanarGraph. The convention adopted is the following:

Version:
$Id: TripartiteEmbeddedPlanarGraph.java,v 1.24 2001/10/18 15:39:06 lv Exp $
Author:
David Jackson, Baolin Yang, Benoit Hudson, Luca Vismara

Inner classes inherited from class jdsl.graph.ref.AbstractGraph
AbstractGraph.OO_to_O_MergerIterator
 
Field Summary
protected  TripartiteEmbeddedPlanarGraph dual_
          The dual of this graph
protected static int DUAL_INDEX
           
protected  int dualIndex_
           
protected static java.lang.Object MARKED
           
protected static int PRIMAL_INDEX
           
protected  int thisIndex_
           
protected  OrderedGraph tripartite_
          The underlying representation of the graph
 
Constructor Summary
  TripartiteEmbeddedPlanarGraph()
          Creates an initial embedded planar graph consisting of a single vertex, no edges, and one face (the external face).
protected TripartiteEmbeddedPlanarGraph(TripartiteEmbeddedPlanarGraph primal)
          Invoked by createDual().
 
Method Summary
 Face aCommonFace(Edge e1, Edge e2)
          O(1)
 Face aCommonFace(Vertex v1, Vertex v2)
          O(degree(v1)+degree(v2))
 FaceIterator adjacentFaces(Face f)
          O(degree(f))
 Face aFace()
          in the current implementation there is always at least one face O(1)
 Edge anEdge()
          O(1)
 Edge anIncidentEdge(Face f)
          O(1)
 Edge anIncidentEdge(Vertex v)
          O(1)
 Edge anIncidentEdge(Vertex v, int edgetype)
          O(degree(v))
 Face anIncidentFace(Vertex v)
          O(1)
 Vertex anIncidentVertex(Face f)
          O(1)
 boolean areAdjacent(Edge e1, Edge e2)
          O(1)
 boolean areAdjacent(Face f1, Face f2)
          O(min(degree(f1),degree(f2)))
 boolean areIncident(Edge e, Face f)
          O(1)
 boolean areIncident(Vertex v, Edge e)
          O(1)
 boolean areIncident(Vertex v, Face f)
          O(degree(v))
 Edge attachVertex(Vertex v, Order order, Edge e, Face f, java.lang.Object vertexInfo, java.lang.Object edgeInfo)
          O(1)
 Edge attachVertexFrom(Vertex origin, Order order, Edge e, Face f, java.lang.Object vertexInfo, java.lang.Object edgeInfo)
          O(1)
 Edge attachVertexTo(Vertex destination, Order order, Edge e, Face f, java.lang.Object vertexInfo, java.lang.Object edgeInfo)
          O(1)
 Vertex aVertex()
          O(1)
 EdgeIterator connectingEdges(Face f1, Face f2)
          O(min(degree(f1),degree(f2)))
 boolean contains(Accessor p)
          O(1)
protected  void createDual()
          Allows overriding this class to create a modified dual.
 int degree(Face f)
          O(1)
 int degree(Vertex v)
          O(1)
 int degree(Vertex v, int edgetype)
          O(degree(v))
 Vertex destination(Edge e)
          O(1)
 EmbeddedPlanarGraph dual()
           
 Edge dual(Edge e)
          O(1)
 Vertex dual(Face f)
          O(1)
 Face dual(Vertex v)
          O(1)
 EdgeIterator edges()
          O(m)
 ObjectIterator elements()
          O(n+m+l)
 Vertex[] endVertices(Edge e)
          O(1)
 FaceIterator faces()
          O(l)
 Edge incidentEdge(Face f, Order order, Edge e, Vertex v)
          O(1) Implemented through the dual graph
 Edge incidentEdge(Vertex v, Order order, Edge e, Face f)
          O(1)
 EdgeIterator incidentEdges(Face f)
          O(degree(f))
 EdgeIterator incidentEdges(Vertex v)
          O(degree(v))
 EdgeIterator incidentEdges(Vertex v, int edgetype)
          O(degree(v))
 Face incidentFace(Vertex v, Order order, Edge e)
           
 Face[] incidentFaces(Edge e)
          O(1)
 FaceIterator incidentFaces(Vertex v)
          O(degree(v))
 Vertex incidentVertex(Face f, Order order, Edge e)
           
 VertexIterator incidentVertices(Face f)
          O(degree(f))
 Edge insertDirectedEdge(Vertex v1, Order order1, Edge e1, Vertex v2, Order order2, Edge e2, Face f, java.lang.Object info)
          Inserts a new directed edge from an existing origin vertex to an existing destination vertex in a specified order; the two vertices must be incident on a common face.
 Edge insertEdge(Vertex v1, Order order1, Edge e1, Vertex v2, Order order2, Edge e2, Face f, java.lang.Object info)
          O(degree(face)), where face is the face split by the insertion of the new edge
 InspectableEmbeddedPlanarGraph inspectableDual()
          O(1)
 boolean isDirected(Edge e)
          O(1)
 Face leftFace(Edge e)
          O(1)
static void main(java.lang.String[] argv)
           
 void makeUndirected(Edge e)
          O(1)
 Container newContainer()
          O(1)
 int numEdges()
          O(1)
 int numFaces()
          O(1)
 int numVertices()
          O(1)
 Face opposite(Face f, Edge e)
          O(1)
 Vertex opposite(Vertex v, Edge e)
          O(1)
 Vertex origin(Edge e)
          O(1)
 PositionIterator positions()
          O(n+m+l)
 Face removeEdge(Edge e)
          O(1)
 Face removeVertex(Vertex v)
          O(degree(v))
 java.lang.Object replaceElement(Accessor p, java.lang.Object newElement)
          O(1)
 void reverseDirection(Edge e)
          O(1)
 Face rightFace(Edge e)
          O(1)
 void setDirectionFrom(Edge e, Vertex newOrigin)
          O(1)
 void setDirectionTo(Edge e, Vertex newDestination)
          O(1)
 void setLeftFace(Edge e, Face f)
          O(1)
 void setRightFace(Edge e, Face f)
          O(1)
 int size()
          O(1)
 Vertex splitEdge(Edge e, java.lang.Object info)
          O(1)
 Edge splitVertex(Vertex v, Edge e1, Face f1, Edge e2, Face f2, java.lang.Object edgeInfo)
          Splits an existing vertex into two new vertices connected by a new edge.
 Edge unsplitEdge(Vertex v, java.lang.Object info)
          O(1)
 Vertex unsplitVertex(Edge e, java.lang.Object vertexInfo)
          Merges two adjacent vertices and removes the edge(s) connecting them.
 VertexIterator vertices()
          O(n)
 
Methods inherited from class jdsl.graph.ref.AbstractGraph
aCommonVertex, aConnectingEdge, adjacentVertices, adjacentVertices, areAdjacent, connectingEdges, directedEdges, undirectedEdges
 
Methods inherited from class jdsl.core.ref.AbstractPositionalContainer
isEmpty, swapElements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jdsl.graph.api.InspectableGraph
aCommonVertex, aConnectingEdge, adjacentVertices, adjacentVertices, areAdjacent, connectingEdges, directedEdges, undirectedEdges
 
Methods inherited from interface jdsl.core.api.InspectableContainer
isEmpty
 
Methods inherited from interface jdsl.core.api.PositionalContainer
swapElements
 

Field Detail

PRIMAL_INDEX

protected static final int PRIMAL_INDEX

DUAL_INDEX

protected static final int DUAL_INDEX

MARKED

protected static final java.lang.Object MARKED

thisIndex_

protected final int thisIndex_

dualIndex_

protected final int dualIndex_

tripartite_

protected OrderedGraph tripartite_
The underlying representation of the graph

dual_

protected TripartiteEmbeddedPlanarGraph dual_
The dual of this graph
Constructor Detail

TripartiteEmbeddedPlanarGraph

public TripartiteEmbeddedPlanarGraph()
Creates an initial embedded planar graph consisting of a single vertex, no edges, and one face (the external face).

TripartiteEmbeddedPlanarGraph

protected TripartiteEmbeddedPlanarGraph(TripartiteEmbeddedPlanarGraph primal)
Invoked by createDual().
Method Detail

createDual

protected void createDual()
Allows overriding this class to create a modified dual. This is pretty much required for a nice subclass of this.

contains

public boolean contains(Accessor p)
O(1)
Specified by:
contains in interface InspectableContainer
Following copied from interface: jdsl.core.api.InspectableContainer
Throws:
InvalidAccessorException - if a is null

elements

public ObjectIterator elements()
O(n+m+l)
Specified by:
elements in interface InspectableContainer
Following copied from interface: jdsl.core.api.InspectableContainer
Returns:
an iterator over all the elements stored in this container

size

public int size()
O(1)
Specified by:
size in interface InspectableContainer
Overrides:
size in class AbstractGraph
Following copied from interface: jdsl.core.api.InspectableContainer
Returns:
Number of elements stored by the container.

newContainer

public Container newContainer()
O(1)
Specified by:
newContainer in interface Container
Following copied from interface: jdsl.core.api.Container
Returns:
A new, empty Container of the same class as this one.

replaceElement

public java.lang.Object replaceElement(Accessor p,
                                       java.lang.Object newElement)
O(1)
Specified by:
replaceElement in interface Container
Following copied from interface: jdsl.core.api.Container
Parameters:
a - Accessor in this container
newElement - to be stored at a
Returns:
old element, previously stored at a
Throws:
InvalidAccessorException - if a is null or does not belong to this container

positions

public PositionIterator positions()
O(n+m+l)
Specified by:
positions in interface InspectablePositionalContainer
Overrides:
positions in class AbstractGraph
Following copied from interface: jdsl.core.api.InspectablePositionalContainer
Returns:
A PositionIterator over all positions in the container

degree

public int degree(Vertex v)
           throws InvalidAccessorException
O(1)
Specified by:
degree in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
Returns:
the number of edges (directed and undirected) incident with v
Throws:
InvalidAccessorException - if v is not contained in this graph

degree

public int degree(Vertex v,
                  int edgetype)
           throws InvalidAccessorException
O(degree(v))
Specified by:
degree in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
edgetype - A constant from the EdgeDirection interface
Returns:
the number of edges of the specified type incident with v
Throws:
InvalidAccessorException - if v is not contained in this graph
See Also:
EdgeDirection

numVertices

public int numVertices()
O(1)
Specified by:
numVertices in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Returns:
the number of vertices

numEdges

public int numEdges()
O(1)
Specified by:
numEdges in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Returns:
the number of edges

vertices

public VertexIterator vertices()
O(n)
Specified by:
vertices in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Returns:
an iterator over all vertices in the graph

edges

public EdgeIterator edges()
O(m)
Specified by:
edges in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Returns:
an iterator over all edges in the graph

endVertices

public Vertex[] endVertices(Edge e)
                     throws InvalidAccessorException
O(1)
Specified by:
endVertices in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
e - an edge
Returns:
an array (of size 2) containing the two endvertices of e; if e is directed, the first element of the array is the origin of e and the second element is the destination of e
Throws:
InvalidAccessorException - if e is not contained in this graph

origin

public Vertex origin(Edge e)
              throws InvalidAccessorException,
                     InvalidEdgeException
O(1)
Specified by:
origin in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
e - an edge
Returns:
the origin vertex of e, if e is directed
Throws:
InvalidEdgeException - if e is undirected
InvalidAccessorException - if e is not contained in this graph

destination

public Vertex destination(Edge e)
                   throws InvalidAccessorException,
                          InvalidEdgeException
O(1)
Specified by:
destination in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
e - an edge
Returns:
the destination vertex of e, if e is directed
Throws:
InvalidEdgeException - if e is undirected
InvalidAccessorException - if e is not contained in this graph

opposite

public Vertex opposite(Vertex v,
                       Edge e)
                throws InvalidVertexException,
                       InvalidAccessorException
O(1)
Specified by:
opposite in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - one endvertex of e
e - an edge
Returns:
the endvertex of e different from v
Throws:
InvalidVertexException - if v is not an endvertex of e
InvalidAccessorException - if v or e is not contained in this graph

isDirected

public boolean isDirected(Edge e)
                   throws InvalidAccessorException
O(1)
Specified by:
isDirected in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
e - an edge
Returns:
true if e is directed, false otherwise
Throws:
InvalidAccessorException - if e is not contained in this graph

aVertex

public Vertex aVertex()
O(1)
Specified by:
aVertex in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Returns:
an arbitrary vertex, or Vertex.NONE if the graph is empty

anEdge

public Edge anEdge()
O(1)
Specified by:
anEdge in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Returns:
an arbitrary edge, or Edge.NONE if the graph has no edges

anIncidentEdge

public Edge anIncidentEdge(Vertex v)
                    throws InvalidAccessorException
O(1)
Specified by:
anIncidentEdge in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
Returns:
any edge incident on v, or Edge.NONE if there is no edge incident on v
Throws:
InvalidAccessorException - if v is not contained in this graph

anIncidentEdge

public Edge anIncidentEdge(Vertex v,
                           int edgetype)
                    throws InvalidAccessorException
O(degree(v))
Specified by:
anIncidentEdge in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
edgetype - A constant from the EdgeDirection interface
Returns:
any edge of the specified type incident on v, or Edge.NONE if there is no such edge incident on v
Throws:
InvalidAccessorException - if v is not contained in this graph
See Also:
EdgeDirection

areIncident

public boolean areIncident(Vertex v,
                           Edge e)
                    throws InvalidAccessorException
O(1)
Specified by:
areIncident in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
e - an edge
Returns:
whether v and e are incident, i.e., whether v is an endvertex of e
Throws:
InvalidAccessorException - if either v or e is not contained in this graph

incidentEdges

public EdgeIterator incidentEdges(Vertex v)
                           throws InvalidAccessorException
O(degree(v))
Specified by:
incidentEdges in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
Returns:
an iterator over all edges incident on v
Throws:
InvalidAccessorException - if v is not contained in this graph

incidentEdges

public EdgeIterator incidentEdges(Vertex v,
                                  int edgetype)
                           throws InvalidAccessorException
O(degree(v))
Specified by:
incidentEdges in interface InspectableGraph
Following copied from interface: jdsl.graph.api.InspectableGraph
Parameters:
v - a vertex
edgetype - A constant from the EdgeDirection interface
Returns:
an iterator over all edges of the specified type incident on v
Throws:
InvalidAccessorException - if v is not contained in this graph
See Also:
EdgeDirection

makeUndirected

public void makeUndirected(Edge e)
                    throws InvalidAccessorException
O(1)
Specified by:
makeUndirected in interface ModifiableGraph
Following copied from interface: jdsl.graph.api.ModifiableGraph
Parameters:
e - an edge
Throws:
InvalidAccessorException - if the edge does not belong to this graph

reverseDirection

public void reverseDirection(Edge e)
                      throws InvalidEdgeException,
                             InvalidAccessorException
O(1)
Specified by:
reverseDirection in interface ModifiableGraph
Following copied from interface: jdsl.graph.api.ModifiableGraph
Parameters:
e - an edge
Throws:
InvalidEdgeException - If the edge is undirected
InvalidAccessorException - if the edge does not belong to this graph

splitEdge

public Vertex splitEdge(Edge e,
                        java.lang.Object info)
                 throws InvalidAccessorException
O(1)
Specified by:
splitEdge in interface ModifiableGraph
Following copied from interface: jdsl.graph.api.ModifiableGraph
Parameters:
e - the edge to be split
vertElement - the object to be stored in v
Returns:
the new vertex w; to get the new edges, use method incidentEdges(w)
Throws:
InvalidAccessorException - if the edge does not belong to this graph

unsplitEdge

public Edge unsplitEdge(Vertex v,
                        java.lang.Object info)
                 throws InvalidAccessorException,
                        InvalidVertexException
O(1)
Specified by:
unsplitEdge in interface ModifiableGraph
Following copied from interface: jdsl.graph.api.ModifiableGraph
Parameters:
v - the vertex to be removed
edgeElement - the element to be stored in the new edge
Returns:
the new edge
Throws:
InvalidVertexException - If the vertex is not of degree 2 or is of degree 2 but the "two" edges are a single self-loop
InvalidAccessorException - if the vertex does not belong to this graph

aFace

public Face aFace()
in the current implementation there is always at least one face O(1)
Specified by:
aFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Returns:
an arbitrary face

numFaces

public int numFaces()
O(1)
Specified by:
numFaces in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Returns:
the number of faces

faces

public FaceIterator faces()
O(l)
Specified by:
faces in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Returns:
an iterator over the faces in the graph

leftFace

public Face leftFace(Edge e)
              throws InvalidAccessorException,
                     InvalidEdgeException
O(1)
Specified by:
leftFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e - a directed edge
Returns:
the face to the left of e
Throws:
InvalidAccessorException - if e is null or not contained in this graph
InvalidEdgeException - if e is not directed

rightFace

public Face rightFace(Edge e)
               throws InvalidAccessorException,
                      InvalidEdgeException
O(1)
Specified by:
rightFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e - a directed edge
Returns:
the face to the right of e
Throws:
InvalidAccessorException - if e is null or not contained in this graph
InvalidEdgeException - if e is not directed

areAdjacent

public boolean areAdjacent(Edge e1,
                           Edge e2)
O(1)
Specified by:
areAdjacent in interface InspectableEmbeddedPlanarGraph
Overrides:
areAdjacent in class AbstractGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e1 - an edge
e2 - an edge
Returns:
whether e1 and e2 are adjacent, i.e., whether they have at least one common endvertex or one common incident face
Throws:
InvalidAccessorException - if either e1 or e2 is null or not contained in this graph

areAdjacent

public boolean areAdjacent(Face f1,
                           Face f2)
O(min(degree(f1),degree(f2)))
Specified by:
areAdjacent in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f1 - a face
f2 - a face
Returns:
whether f1 and f2 are adjacent, i.e., whether they have at least one edge in common
Throws:
InvalidAccessorException - if either f1 or f2 is null or not contained in this graph

areIncident

public boolean areIncident(Edge e,
                           Face f)
                    throws InvalidAccessorException
O(1)
Specified by:
areIncident in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e - an edge
f - a face
Returns:
whether e and f are incident
Throws:
InvalidAccessorException - if either e or f is null or not contained in this graph

areIncident

public boolean areIncident(Vertex v,
                           Face f)
O(degree(v))
Specified by:
areIncident in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v - a vertex
f - a face
Returns:
whether v and f are incident
Throws:
InvalidAccessorException - if either v or f is null or not contained in this graph

inspectableDual

public InspectableEmbeddedPlanarGraph inspectableDual()
O(1)
Specified by:
inspectableDual in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Returns:
the dual inspectable embedded planar graph

anIncidentVertex

public Vertex anIncidentVertex(Face f)
                        throws InvalidAccessorException
O(1)
Specified by:
anIncidentVertex in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
an arbitrary vertex incident with f
Throws:
InvalidAccessorException - if f is null or not contained in this graph

anIncidentEdge

public Edge anIncidentEdge(Face f)
                    throws InvalidAccessorException
O(1)
Specified by:
anIncidentEdge in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
an arbitrary edge incident with f or Edge.NONE if there is no such edge
Throws:
InvalidAccessorException - if f is null or not contained in this graph

anIncidentFace

public Face anIncidentFace(Vertex v)
                    throws InvalidAccessorException
O(1)
Specified by:
anIncidentFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v - a vertex
Returns:
an arbitrary face incident with v
Throws:
InvalidAccessorException - if v is null or not contained in this graph

degree

public int degree(Face f)
           throws InvalidAccessorException
O(1)
Specified by:
degree in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
the number of edges incident with f
Throws:
InvalidAccessorException - if f is null or not contained in this graph

dual

public Face dual(Vertex v)
          throws InvalidAccessorException
O(1)
Specified by:
dual in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v - a vertex
Returns:
the dual face of v
Throws:
InvalidAccessorException - if v is null or not contained in this graph

dual

public Edge dual(Edge e)
          throws InvalidAccessorException
O(1)
Specified by:
dual in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e - an edge
Returns:
the dual edge of e
Throws:
InvalidAccessorException - if e is null or not contained in this graph

dual

public Vertex dual(Face f)
            throws InvalidAccessorException
O(1)
Specified by:
dual in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
the dual vertex of f
Throws:
InvalidAccessorException - if f is null or not contained in this graph

incidentFaces

public Face[] incidentFaces(Edge e)
                     throws InvalidAccessorException
O(1)
Specified by:
incidentFaces in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e - an edge
Returns:
an array (of size 2) containing the two faces incident with e
Throws:
InvalidAccessorException - if e is null or not contained in this graph

adjacentFaces

public FaceIterator adjacentFaces(Face f)
                           throws InvalidAccessorException
O(degree(f))
Specified by:
adjacentFaces in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
an iterator over the faces adjacent to f
Throws:
InvalidAccessorException - if f is null or not contained in this graph

incidentEdges

public EdgeIterator incidentEdges(Face f)
                           throws InvalidAccessorException
O(degree(f))
Specified by:
incidentEdges in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
an iterator over the edges incident with f
Throws:
InvalidAccessorException - if f is null or not contained in this graph

incidentFaces

public FaceIterator incidentFaces(Vertex v)
                           throws InvalidAccessorException
O(degree(v))
Specified by:
incidentFaces in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v - a vertex
Returns:
an iterator over the faces incident with v
Throws:
InvalidAccessorException - if v is null or not contained in this graph

incidentVertices

public VertexIterator incidentVertices(Face f)
                                throws InvalidFaceException
O(degree(f))
Specified by:
incidentVertices in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
Returns:
an iterator over the vertices incident with f
Throws:
InvalidAccessorException - if f is null or not contained in this graph

incidentEdge

public Edge incidentEdge(Vertex v,
                         Order order,
                         Edge e,
                         Face f)
                  throws InvalidAccessorException,
                         InvalidOrderException,
                         InvalidEdgeException,
                         InvalidFaceException
O(1)
Specified by:
incidentEdge in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v - a vertex
order - indicates if the edge to return is the one Order.AFTER_CW or Order.AFTER_CCW e around v
e - an edge incident with v
f - a face incident with e; this parameter is meaningful only if e is a self-loop, otherwise null can be passed
Returns:
the edge incident with v (and f, if e is a self-loop) that comes order e
Throws:
InvalidAccessorException - if v, or e, or f is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e is not an edge incident with v
InvalidFaceException - if f is not a face incident with e

incidentEdge

public Edge incidentEdge(Face f,
                         Order order,
                         Edge e,
                         Vertex v)
                  throws InvalidAccessorException,
                         InvalidOrderException,
                         InvalidEdgeException,
                         InvalidVertexException
O(1) Implemented through the dual graph
Specified by:
incidentEdge in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
order - indicates if the edge to return is the one Order.AFTER_LHS or Order.AFTER_RHS e around f
e - an edge incident with f
v - an endvertex of e; this parameter is meaningful only if e is a bridge, otherwise null can be passed
Returns:
the edge incident with f (and v, if e is a bridge) that comes order e
Throws:
InvalidAccessorException - if f, or e, or v is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_LHS or Order.AFTER_RHS
InvalidEdgeException - if e is not an edge incident with f
InvalidVertexException - if v is not an endvertex of e

incidentFace

public Face incidentFace(Vertex v,
                         Order order,
                         Edge e)
                  throws InvalidAccessorException,
                         InvalidOrderException,
                         InvalidEdgeException,
                         NoUniqueResultException
Specified by:
incidentFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v - a vertex
order - indicates if the face to return is the one Order.AFTER_CW or Order.AFTER_CCW e around v
e - an edge incident with v
Returns:
the face incident with v that comes order e
Throws:
InvalidAccessorException - if v, or e is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e is not an edge incident with v
NoUniqueResultException - if e is a self-loop

incidentVertex

public Vertex incidentVertex(Face f,
                             Order order,
                             Edge e)
                      throws InvalidAccessorException,
                             InvalidOrderException,
                             InvalidEdgeException,
                             InvalidVertexException
Specified by:
incidentVertex in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - a face
order - indicates if the vertex to return is the one Order.AFTER_LHS or Order.AFTER_RHS e around f
e - an edge incident with f
Returns:
the vertex incident with f that comes order e
Throws:
InvalidAccessorException - if f, or e is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_LHS or Order.AFTER_RHS
InvalidEdgeException - if e is not an edge incident with f
NoUniqueResultException - if e is a bridge

aCommonFace

public Face aCommonFace(Edge e1,
                        Edge e2)
                 throws InvalidAccessorException
O(1)
Specified by:
aCommonFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
e1 - an edge
e2 - an edge
Returns:
any face that is incident with both e1 and e2, or Face.NONE if there is no such face
Throws:
InvalidAccessorException - if e1 or e2 is null or not contained in this graph

aCommonFace

public Face aCommonFace(Vertex v1,
                        Vertex v2)
                 throws InvalidAccessorException
O(degree(v1)+degree(v2))
Specified by:
aCommonFace in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
v1 - a vertex
v2 - a vertex
Returns:
any face that is incident with both v1 and v2, or Face.NONE if there is no such face
Throws:
InvalidAccessorException - if v1 or v2 is null or not contained in this graph

connectingEdges

public EdgeIterator connectingEdges(Face f1,
                                    Face f2)
                             throws InvalidAccessorException
O(min(degree(f1),degree(f2)))
Specified by:
connectingEdges in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f1 - a face
f2 - a face
Returns:
an iterator over the edges in common between f1 and f2
Throws:
InvalidAccessorException - if either f1 or f2 is null or not contained in this graph

opposite

public Face opposite(Face f,
                     Edge e)
              throws InvalidAccessorException,
                     InvalidFaceException
O(1)
Specified by:
opposite in interface InspectableEmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.InspectableEmbeddedPlanarGraph
Parameters:
f - one of the two faces incident with e
e - an edge
Returns:
the face incident with e different from f
Throws:
InvalidAccessorException - if either f or e is null or not contained in this graph
InvalidFaceException - if f is not a face incident with e

setDirectionFrom

public void setDirectionFrom(Edge e,
                             Vertex newOrigin)
                      throws InvalidAccessorException,
                             InvalidEdgeException,
                             InvalidVertexException
O(1)
Specified by:
setDirectionFrom in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
e - an edge
v - an endvertex of e
Throws:
InvalidAccessorException - if e or v is null or not contained in this graph
InvalidEdgeException - if e is a self-loop
InvalidVertexException - if v is not an endvertex of e
See Also:
EmbeddedPlanarGraph.setLeftFace(Edge,Face), EmbeddedPlanarGraph.setRightFace(Edge,Face)

setDirectionTo

public void setDirectionTo(Edge e,
                           Vertex newDestination)
                    throws InvalidAccessorException,
                           InvalidEdgeException,
                           InvalidVertexException
O(1)
Specified by:
setDirectionTo in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
e - an edge
v - an endvertex of e
Throws:
InvalidAccessorException - if e or v is null or not contained in this graph
InvalidEdgeException - if e is a self-loop
InvalidVertexException - if v is not an endvertex of e
See Also:
EmbeddedPlanarGraph.setLeftFace(Edge,Face), EmbeddedPlanarGraph.setRightFace(Edge,Face)

removeEdge

public Face removeEdge(Edge e)
                throws InvalidAccessorException,
                       ConnectivityViolationException
O(1)
Specified by:
removeEdge in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
e - the edge to be removed
Returns:
the new face created by the removal of e
Throws:
InvalidAccessorException - if e is null or not contained in this graph
ConnectivityViolationException - if the edge removal disconnects the graph

removeVertex

public Face removeVertex(Vertex v)
                  throws InvalidAccessorException,
                         ConnectivityViolationException
O(degree(v))
Specified by:
removeVertex in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
v - the vertex to be removed
Returns:
the new face created by the removal of v, if degree(v) > 1; the face incident with v, if degree(v) == 1
Throws:
InvalidAccessorException - if v is null or not contained in this graph
ConnectivityViolationException - if the vertex removal disconnects the graph

setLeftFace

public void setLeftFace(Edge e,
                        Face f)
                 throws InvalidAccessorException,
                        InvalidFaceException
O(1)
Specified by:
setLeftFace in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
e - an edge
f - a face incident with e
Throws:
InvalidAccessorException - if e or f is null or not contained in this graph
InvalidFaceException - if f is not incident with e

setRightFace

public void setRightFace(Edge e,
                         Face f)
                  throws InvalidAccessorException,
                         InvalidFaceException
O(1)
Specified by:
setRightFace in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
e - an edge
f - a face incident with e
Throws:
InvalidAccessorException - if e or f is null or not contained in this graph
InvalidFaceException - if f is not incident with e

attachVertex

public Edge attachVertex(Vertex v,
                         Order order,
                         Edge e,
                         Face f,
                         java.lang.Object vertexInfo,
                         java.lang.Object edgeInfo)
                  throws InvalidAccessorException,
                         InvalidOrderException,
                         InvalidEdgeException,
                         InvalidFaceException
O(1)
Specified by:
attachVertex in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
v - a vertex
order - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e around v
e - an edge incident with v or Edge.NONE if v is an isolated vertex
f - a face incident with e; this parameter is meaningful only if e is a self-loop, otherwise null can be passed; the new vertex and the new edge will be incident with this face
vertexInfo - the object to be stored in the new vertex and in its dual face
edgeInfo - the object to be stored in the new edge and in its dual edge
Returns:
the new edge e'. To get the new vertex, use method opposite(v,e')
Throws:
InvalidAccessorException - if v or e (or f, if meaningful) is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e is not an edge incident with v, or if Edge.NONE is passed as the edge parameter and v is not an isolated vertex, or if Edge.NONE is not passed as the edge parameter and v is an isolated vertex
InvalidFaceException - if e is a self-loop and f is not a face incident with e
See Also:
InspectableGraph.opposite(Vertex,Edge)

attachVertexFrom

public Edge attachVertexFrom(Vertex origin,
                             Order order,
                             Edge e,
                             Face f,
                             java.lang.Object vertexInfo,
                             java.lang.Object edgeInfo)
                      throws InvalidAccessorException,
                             InvalidOrderException,
                             InvalidEdgeException,
                             InvalidFaceException
O(1)
Specified by:
attachVertexFrom in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
origin - a vertex
order - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e around v
e - an edge incident with v or Edge.NONE if v is an isolated vertex
f - a face incident with e; this parameter is meaningful only if e is a self-loop, otherwise null can be passed; the new vertex and the new edge will be incident with this face
vertexInfo - the object to be stored in the new vertex and in its dual face
edgeInfo - the object to be stored in the new edge and in its dual edge
Returns:
the new edge e'. To get the new vertex, use method opposite(v,e')
Throws:
InvalidAccessorException - if v or e (or f, if meaningful) is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e is not an edge incident with v, or if Edge.NONE is passed as the edge parameter and v is not an isolated vertex, or if Edge.NONE is not passed as the edge parameter and v is an isolated vertex
InvalidFaceException - if e is a self-loop and f is not a face incident with e
See Also:
InspectableGraph.opposite(Vertex,Edge)

attachVertexTo

public Edge attachVertexTo(Vertex destination,
                           Order order,
                           Edge e,
                           Face f,
                           java.lang.Object vertexInfo,
                           java.lang.Object edgeInfo)
                    throws InvalidAccessorException,
                           InvalidOrderException,
                           InvalidEdgeException,
                           InvalidFaceException
O(1)
Specified by:
attachVertexTo in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
destination - a vertex
order - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e around v
e - an edge incident with v or Edge.NONE if v is an isolated vertex
f - a face incident with e; this parameter is meaningful only if e is a self-loop, otherwise null can be passed; the new vertex and the new edge will be incident with this face
vertexInfo - the object to be stored in the new vertex and in its dual face
edgeInfo - the object to be stored in the new edge and in its dual edge
Returns:
the new edge e'. To get the new vertex, use method opposite(v,e')
Throws:
InvalidAccessorException - if v or e (or f, if meaningful) is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e is not an edge incident with v, or if Edge.NONE is passed as the edge parameter and v is not an isolated vertex, or if Edge.NONE is not passed as the edge parameter and v is an isolated vertex
InvalidFaceException - if e is a self-loop and f is not a face incident with e
See Also:
InspectableGraph.opposite(Vertex,Edge)

insertEdge

public Edge insertEdge(Vertex v1,
                       Order order1,
                       Edge e1,
                       Vertex v2,
                       Order order2,
                       Edge e2,
                       Face f,
                       java.lang.Object info)
                throws InvalidAccessorException,
                       InvalidOrderException,
                       InvalidEdgeException,
                       InvalidFaceException,
                       PlanarityViolationException
O(degree(face)), where face is the face split by the insertion of the new edge
Specified by:
insertEdge in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
v1 - the first endvertex
order1 - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e1 around v1
e1 - an edge incident with v1 or Edge.NONE if v is an isolated vertex
v2 - the second endvertex
order2 - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e2 around v2
e2 - an edge incident with v2 or Edge.NONE if v is an isolated vertex
f - a face incident with e1 (e2); this parameter is meaningful only if e1 (e2) is a self-loop, otherwise null can be passed; the new edge will split this face
info - the object to be stored in the new edge and in its dual edge
Returns:
the new edge
Throws:
InvalidAccessorException - if v1, e1, v2, or e2 (or f, if meaningful) is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e1 (e2) is not an edge incident with v1 (v2), or if Edge.NONE is passed as the edge parameter and v1 (v2) is not an isolated vertex, or if Edge.NONE is not passed as the edge parameter and v1 (v2) is an isolated vertex
InvalidFaceException - if e1 (e2) is a self-loop and f is not a face incident with e1 (e2)
PlanarityViolationException - if the face identified by v1, order1, e1 is different from the face identified by v2, order2, e2

insertDirectedEdge

public Edge insertDirectedEdge(Vertex v1,
                               Order order1,
                               Edge e1,
                               Vertex v2,
                               Order order2,
                               Edge e2,
                               Face f,
                               java.lang.Object info)
                        throws InvalidAccessorException,
                               InvalidOrderException,
                               InvalidEdgeException,
                               InvalidFaceException,
                               PlanarityViolationException
Description copied from interface: EmbeddedPlanarGraph
Inserts a new directed edge from an existing origin vertex to an existing destination vertex in a specified order; the two vertices must be incident on a common face. The common face is removed; its element() can still be retrieved. Two new adjacent faces storing null are inserted.
Specified by:
insertDirectedEdge in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
v1 - the origin vertex
order1 - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e1 around v1
e1 - an edge incident with v1 or Edge.NONE if v is an isolated vertex
v2 - the destination vertex
order2 - indicates if the new edge is to be inserted Order.AFTER_CW or Order.AFTER_CCW e2 around v2
e2 - an edge incident with v2 or Edge.NONE if v is an isolated vertex
f - a face incident with e1 (v2); this parameter is meaningful only if e1 (e2) is a self-loop, otherwise null can be passed; the new edge will split this face
info - the object to be stored in the new edge and in its dual edge
Returns:
the new edge
Throws:
InvalidAccessorException - if v1, e1, v2, or e2 (or f, if meaningful) is null or not contained in this graph
InvalidOrderException - if order is different from Order.AFTER_CW or Order.AFTER_CCW
InvalidEdgeException - if e1 (e2) is not an edge incident with v1 (v2), or if Edge.NONE is passed as the edge parameter and v1 (v2) is not an isolated vertex, or if Edge.NONE is not passed as the edge parameter and v1 (v2) is an isolated vertex
InvalidFaceException - if e1 (e2) is a self-loop and f is not a face incident with e1 (e2)
PlanarityViolationException - if the face identified by v1, order1, e1 is different from the face identified by v2, order2, e2

splitVertex

public Edge splitVertex(Vertex v,
                        Edge e1,
                        Face f1,
                        Edge e2,
                        Face f2,
                        java.lang.Object edgeInfo)
                 throws InvalidAccessorException,
                        InvalidEdgeException,
                        InvalidFaceException
Description copied from interface: EmbeddedPlanarGraph
Splits an existing vertex into two new vertices connected by a new edge. The old vertex is removed (if you need its element, get it beforehand). The new vertices store null elements, and the new edge stores the parameter edgeinfo. The edges incident with v from e1 Order.AFTER_CW to e2 (inclusive) are incident with one new vertex; the other edges are incident with the other new vertex.
          e1                 e1
       \ /            \     /
       -O-     --->   -O---O-
       / \            /     \
          e2                 e2
 
Specified by:
splitVertex in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
v - the vertex to be split
e1 - an edge incident with v or Edge.NONE if v is an isolated vertex
f1 - a face incident with e1; this parameter is meaningful only if e1 is a self-loop, otherwise null can be passed; the new edge will be incident with this face
e2 - an edge incident with v or Edge.NONE if v is an isolated vertex
f2 - a face incident with e2; this parameter is meaningful only if e2 is a self-loop, otherwise null can be passed; the new edge will be incident with this face
edgeinfo - the object to be stored in the new edge and in its dual edge
Returns:
the new edge e'; to get the new vertices, use method endVertices(e')
Throws:
InvalidAccessorException - if v, e1, or e2 (or f1 or f2, if meaningful) is null or not contained in this graph
InvalidEdgeException - if e1 or e2 is not an edge incident with v, or if Edge.NONE is passed as e1 or e2 and v is not an isolated vertex, or if Edge.NONE is not passed as e1 and e2 and v is an isolated vertex
InvalidFaceException - if e1 (e2) is a self-loop and f1 (f2) is not a face incident with e1 (e2)
See Also:
InspectableGraph.endVertices(Edge)

unsplitVertex

public Vertex unsplitVertex(Edge e,
                            java.lang.Object vertexInfo)
                     throws InvalidAccessorException,
                            InvalidEdgeException
Description copied from interface: EmbeddedPlanarGraph
Merges two adjacent vertices and removes the edge(s) connecting them. The edge(s) and the vertices are removed (if you need their elements, get them beforehand), and a new vertex is inserted in their place. The new vertex stores the vertexinfo parameter.
       \  e  /          \ /
       -O---O-   --->   -O-
       /     \          / \
 
Specified by:
unsplitVertex in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Parameters:
e - the edge to be removed
vertexinfo - the object to be stored in the new vertex and in its dual face
Returns:
the new vertex
Throws:
InvalidAccessorException - if e is null or not contained in this graph
InvalidEdgeException - if e is a self-loop

dual

public EmbeddedPlanarGraph dual()
Specified by:
dual in interface EmbeddedPlanarGraph
Following copied from interface: jdsl.map.api.EmbeddedPlanarGraph
Returns:
the dual embedded planar graph

main

public static void main(java.lang.String[] argv)