Savarese Software Research

com.savarese.algorithms.graph
Interface Graph<V,E extends Edge<V,?>>

All Known Implementing Classes:
AdjacencyList

public interface Graph<V,E extends Edge<V,?>>

A Graph is a collection of vertices and the edges emanating from them.

Author:
Daniel F. Savarese

Method Summary
 void add(E edge)
          Adds an edge to the graph, mapping the source vertex to the edge.
 void addVertex(V vertex)
          Adds a vertex to the graph with no edges associated with it.
 void clear()
          Removes all vertices and edges from the graph.
 java.util.Set<E> edgeSet(V v)
          Returns a set containing all of the edges emanating from a given vertex.
 int size()
          Returns the number of vertices in the graph.
 java.util.Set<V> vertexSet()
          Returns the set of vertices in the graph.
 

Method Detail

add

void add(E edge)
Adds an edge to the graph, mapping the source vertex to the edge.

Parameters:
edge - The edge to add.

addVertex

void addVertex(V vertex)
Adds a vertex to the graph with no edges associated with it. If the vertex is already contained in the graph, no change is made to the graph.

Parameters:
vertex - The vertex to add.

clear

void clear()
Removes all vertices and edges from the graph.


edgeSet

java.util.Set<E> edgeSet(V v)
Returns a set containing all of the edges emanating from a given vertex.

Parameters:
v - A source vertex.
Returns:
A set containing all of the edges emanating from a given vertex. If the vertex has no edges, the set will be empty. If the vertex is not containied in the graph, null will be returned.

size

int size()
Returns the number of vertices in the graph.

Returns:
The number of vertices in the graph.

vertexSet

java.util.Set<V> vertexSet()
Returns the set of vertices in the graph.

Returns:
The set of vertices in the graph.

Savarese Software Research

Copyright © 2004-2005 Savarese Software Research and Daniel F. Savarese. All Rights Reserved.