jdsl.core.api
Interface Graph

All Known Implementing Classes:
SILGraph, FastSILGraph

public abstract interface Graph
extends InspectableGraph

An interface describing a graph as a combinatorial object. Holds both directed and undirected edges. Note that the Vertex and Edge interfaces are subinterfaces of jdsl.core.api.Position -- empty subinterfaces, for type safety only.

Author:
Mike Boilen

Method Summary
 Edge insertDirectedEdge(Vertex u, Vertex v, java.lang.Object info)
          Inserts a new directed edge from an existing vertex to another.
 Edge insertEdge(Vertex u, Vertex v, java.lang.Object info)
          Inserts a new undirected edge between two existing vertices.
 Vertex insertVertex(java.lang.Object info)
          Inserts a new isolated vertex containing an object.
 void makeUndirected(Edge e)
          Makes a directed edge undirected.
 java.lang.Object removeEdge(Edge e)
          Removes an edge.
 java.lang.Object removeVertex(Vertex v)
          Deletes a vertex and all its incident edges.
 void reverseDirection(Edge e)
          Reverse the direction of an edge.
 void setDirectionFrom(Edge e, Vertex newOrigin)
          Sets the direction of an edge away from a vertex.
 void setDirectionTo(Edge e, Vertex newDestination)
          Sets the direction of an edge towards a vertex.
 
Methods inherited from interface jdsl.core.api.InspectableGraph
adjacentVertices, degree, destination, directedEdges, edges, endVertices, inAdjacentVertices, incidentEdges, inDegree, inIncidentEdges, isDirected, numEdges, numVertices, opposite, origin, outAdjacentVertices, outDegree, outIncidentEdges, undirectedEdges, vertices
 
Methods inherited from interface jdsl.core.api.PositionalContainer
positions, replace, swap
 
Methods inherited from interface jdsl.core.api.Container
elements, newContainer
 
Methods inherited from interface jdsl.simple.api.SimpleContainer
isEmpty, size
 

Method Detail

insertVertex

public Vertex insertVertex(java.lang.Object info)
                    throws InvalidPositionException
Inserts a new isolated vertex containing an object.
Parameters:
info - the object to be stored in the new vertex
Returns:
the new vertex

insertEdge

public Edge insertEdge(Vertex u,
                       Vertex v,
                       java.lang.Object info)
                throws InvalidPositionException
Inserts a new undirected edge between two existing vertices.
Parameters:
u - the first endvertex
v - the second endvertex
Returns:
the new edge

insertDirectedEdge

public Edge insertDirectedEdge(Vertex u,
                               Vertex v,
                               java.lang.Object info)
                        throws InvalidPositionException
Inserts a new directed edge from an existing vertex to another.
Parameters:
u - the origin vertex
v - the destination vertex
Returns:
the new edge

removeVertex

public java.lang.Object removeVertex(Vertex v)
                              throws InvalidPositionException
Deletes a vertex and all its incident edges. If you need the locators stored at the removed edges, get the locators beforehand.

Parameters:
v - the vertex to be deleted
Returns:
Locator formerly stored at v

removeEdge

public java.lang.Object removeEdge(Edge e)
                            throws InvalidPositionException
Removes an edge.
Parameters:
e - the edge to be removed
Returns:
The removed edge's element

setDirectionFrom

public void setDirectionFrom(Edge e,
                             Vertex newOrigin)
                      throws InvalidEdgeException,
                             InvalidPositionException
Sets the direction of an edge away from a vertex. Makes an undirected edge directed.
Parameters:
e - an edge
v - an endvertex of e
Throws:
InvalidEdgeException - When v is not an endpoint of e

setDirectionTo

public void setDirectionTo(Edge e,
                           Vertex newDestination)
                    throws InvalidEdgeException,
                           InvalidPositionException
Sets the direction of an edge towards a vertex. Makes an undirected edge directed.
Parameters:
e - an edge
v - an endvertex of e
Throws:
InvalidEdgeException - When v is not an endpoint of e

makeUndirected

public void makeUndirected(Edge e)
                    throws InvalidEdgeException
Makes a directed edge undirected. Does nothing if the edge is undirected.
Parameters:
e - an edge

reverseDirection

public void reverseDirection(Edge e)
                      throws InvalidEdgeException,
                             InvalidPositionException
Reverse the direction of an edge.
Parameters:
e - an edge
Throws:
InvalidEdgeException - If the edge is undirected