net.datastructures - version 5.0

net.datastructures
Interface Graph<V,E>

All Known Implementing Classes:
AdjacencyListGraph

public interface Graph<V,E>

An interface for a graph.

Author:
Roberto Tamassia

Method Summary
 boolean areAdjacent(Vertex<V> u, Vertex<V> v)
          Tests whether two vertices are adjacent
 Iterable<Edge<E>> edges()
          Returns the edges of the graph as an iterable collection
 Vertex[] endVertices(Edge<E> e)
          Returns the endvertices of a vertex as an array of length 2
 Iterable<Edge<E>> incidentEdges(Vertex<V> v)
          Returns the edges incident on a vertex as an iterable collection
 Edge<E> insertEdge(Vertex<V> u, Vertex<V> v, E o)
          Inserts and return a new edge with a given element between two vertices
 Vertex<V> insertVertex(V o)
          Inserts and return a new vertex with a given element
 int numEdges()
          Returns the number of edges of the graph
 int numVertices()
          Returns the number of vertices of the graph
 Vertex<V> opposite(Vertex<V> v, Edge<E> e)
          Returns the other endvertex of an incident edge
 E removeEdge(Edge<E> e)
          Removes an edge and return its element
 V removeVertex(Vertex<V> v)
          Removes a vertex and all its incident edges and returns the element stored at the removed vertex
 E replace(Edge<E> p, E o)
          Replaces the element of a given edge with a new element and returns the old element
 V replace(Vertex<V> p, V o)
          Replaces the element of a given vertex with a new element and returns the old element
 Iterable<Vertex<V>> vertices()
          Returns the vertices of the graph as an iterable collection
 

Method Detail

numVertices

int numVertices()
Returns the number of vertices of the graph


numEdges

int numEdges()
Returns the number of edges of the graph


vertices

Iterable<Vertex<V>> vertices()
Returns the vertices of the graph as an iterable collection


edges

Iterable<Edge<E>> edges()
Returns the edges of the graph as an iterable collection


replace

V replace(Vertex<V> p,
          V o)
          throws InvalidPositionException
Replaces the element of a given vertex with a new element and returns the old element

Throws:
InvalidPositionException

replace

E replace(Edge<E> p,
          E o)
          throws InvalidPositionException
Replaces the element of a given edge with a new element and returns the old element

Throws:
InvalidPositionException

incidentEdges

Iterable<Edge<E>> incidentEdges(Vertex<V> v)
                                throws InvalidPositionException
Returns the edges incident on a vertex as an iterable collection

Throws:
InvalidPositionException

endVertices

Vertex[] endVertices(Edge<E> e)
                     throws InvalidPositionException
Returns the endvertices of a vertex as an array of length 2

Throws:
InvalidPositionException

opposite

Vertex<V> opposite(Vertex<V> v,
                   Edge<E> e)
                   throws InvalidPositionException
Returns the other endvertex of an incident edge

Throws:
InvalidPositionException

areAdjacent

boolean areAdjacent(Vertex<V> u,
                    Vertex<V> v)
                    throws InvalidPositionException
Tests whether two vertices are adjacent

Throws:
InvalidPositionException

insertVertex

Vertex<V> insertVertex(V o)
Inserts and return a new vertex with a given element


insertEdge

Edge<E> insertEdge(Vertex<V> u,
                   Vertex<V> v,
                   E o)
                   throws InvalidPositionException
Inserts and return a new edge with a given element between two vertices

Throws:
InvalidPositionException

removeVertex

V removeVertex(Vertex<V> v)
               throws InvalidPositionException
Removes a vertex and all its incident edges and returns the element stored at the removed vertex

Throws:
InvalidPositionException

removeEdge

E removeEdge(Edge<E> e)
             throws InvalidPositionException
Removes an edge and return its element

Throws:
InvalidPositionException

net.datastructures - version 5.0