datastructures

net.datastructures
Interface Graph

All Known Implementing Classes:
AdjacencyListGraph

public interface Graph

An interface for a graph.

Author:
Roberto Tamassia

Method Summary
 boolean areAdjacent(Vertex u, Vertex v)
          Test whether two vertices are adjacent
 Iterator edges()
          Return an iterator over the edges of the graph
 Vertex[] endVertices(Edge e)
          Return the endvertices of a vertex as an array of length 2
 Iterator incidentEdges(Vertex v)
          Return an iterator over the edges incident on a vertex
 Edge insertEdge(Vertex u, Vertex v, Object o)
          Insert and return a new edge with a given element between two vertices
 Vertex insertVertex(Object o)
          Insert and return a new vertex with a given element
 Vertex opposite(Vertex v, Edge e)
          Return the other endvertex of an incident edge
 Object removeEdge(Edge e)
          Remove an edge and return its element
 Object removeVertex(Vertex v)
          Remove a vertex and all its incident edges and return the element stored at the removed vertex
 Object replace(Position p, Object o)
          Replace the element a given position (vertex or edge) with a new element and return the old element
 Iterator vertices()
          Return an iterator over the vertices of the graph
 

Method Detail

vertices

public Iterator vertices()
Return an iterator over the vertices of the graph


edges

public Iterator edges()
Return an iterator over the edges of the graph


replace

public Object replace(Position p,
                      Object o)
               throws InvalidPositionException
Replace the element a given position (vertex or edge) with a new element and return the old element

Throws:
InvalidPositionException

incidentEdges

public Iterator incidentEdges(Vertex v)
                       throws InvalidPositionException
Return an iterator over the edges incident on a vertex

Throws:
InvalidPositionException

endVertices

public Vertex[] endVertices(Edge e)
                     throws InvalidPositionException
Return the endvertices of a vertex as an array of length 2

Throws:
InvalidPositionException

opposite

public Vertex opposite(Vertex v,
                       Edge e)
                throws InvalidPositionException
Return the other endvertex of an incident edge

Throws:
InvalidPositionException

areAdjacent

public boolean areAdjacent(Vertex u,
                           Vertex v)
                    throws InvalidPositionException
Test whether two vertices are adjacent

Throws:
InvalidPositionException

insertVertex

public Vertex insertVertex(Object o)
Insert and return a new vertex with a given element


insertEdge

public Edge insertEdge(Vertex u,
                       Vertex v,
                       Object o)
                throws InvalidPositionException
Insert and return a new edge with a given element between two vertices

Throws:
InvalidPositionException

removeVertex

public Object removeVertex(Vertex v)
                    throws InvalidPositionException
Remove a vertex and all its incident edges and return the element stored at the removed vertex

Throws:
InvalidPositionException

removeEdge

public Object removeEdge(Edge e)
                  throws InvalidPositionException
Remove an edge and return its element

Throws:
InvalidPositionException

datastructures