Savarese Software Research

com.savarese.algorithms.graph
Class AdjacencyList<V,E extends Edge<V,?>>

java.lang.Object
  extended by com.savarese.algorithms.graph.AdjacencyList<V,E>
All Implemented Interfaces:
Graph<V,E>

public class AdjacencyList<V,E extends Edge<V,?>>
extends java.lang.Object
implements Graph<V,E>

An AdjacencyList represents a graph by mapping a set of vertices to the set of edges emanating from each vertex.

Author:
Daniel F. Savarese

Constructor Summary
AdjacencyList()
          Creates an empty adjacency list.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdjacencyList

public AdjacencyList()
Creates an empty adjacency list.

Method Detail

add

public void add(E edge)
Description copied from interface: Graph
Adds an edge to the graph, mapping the source vertex to the edge.

Specified by:
add in interface Graph<V,E extends Edge<V,?>>
Parameters:
edge - The edge to add.

addVertex

public void addVertex(V vertex)
Description copied from interface: Graph
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.

Specified by:
addVertex in interface Graph<V,E extends Edge<V,?>>
Parameters:
vertex - The vertex to add.

clear

public void clear()
Description copied from interface: Graph
Removes all vertices and edges from the graph.

Specified by:
clear in interface Graph<V,E extends Edge<V,?>>

edgeSet

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

Specified by:
edgeSet in interface Graph<V,E extends Edge<V,?>>
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

public int size()
Description copied from interface: Graph
Returns the number of vertices in the graph.

Specified by:
size in interface Graph<V,E extends Edge<V,?>>
Returns:
The number of vertices in the graph.

vertexSet

public java.util.Set<V> vertexSet()
Description copied from interface: Graph
Returns the set of vertices in the graph.

Specified by:
vertexSet in interface Graph<V,E extends Edge<V,?>>
Returns:
The set of vertices in the graph.

Savarese Software Research

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