edu.umd.cs.findbugs.graph

Interface Graph<EdgeType,VertexType>

public interface Graph<EdgeType extends GraphEdge<EdgeType,VertexType>,VertexType extends GraphVertex<VertexType>>

Graph interface; defines the operations used to access and manipulate a graph.
Method Summary
voidaddVertex(VertexType v)
Add given vertex to the graph.
booleancontainsVertex(VertexType v)
Determine if the graph contains the given vertex.
EdgeTypecreateEdge(VertexType source, VertexType target)
Add a new edge to the graph.
Iterator<EdgeType>edgeIterator()
Get Iterator over all edges in the graph.
intgetNumEdgeLabels()
Get the number of numeric labels that have been assigned to edges.
intgetNumEdges()
Get number of edges in the graph.
intgetNumIncomingEdges(VertexType vertex)
Get number of edges going into given vertex.
intgetNumOutgoingEdges(VertexType vertex)
Get number of edges going out of given vertex.
intgetNumVertexLabels()
Get the number of numeric (integer) labels that have been assigned to vertices in the graph.
intgetNumVertices()
Get number of vertices in the graph.
Iterator<EdgeType>incomingEdgeIterator(VertexType target)
Get an Iterator over incoming edges to a given vertex.
EdgeTypelookupEdge(VertexType source, VertexType target)
Look up an edge by source and target vertex.
Iterator<EdgeType>outgoingEdgeIterator(VertexType source)
Get an Iterator over outgoing edges from given vertex.
Iterator<VertexType>predecessorIterator(VertexType target)
Get an iterator over the predecessors of this vertex; i.e., the sources of the vertex's incoming edges.
voidremoveEdge(EdgeType e)
Remove given edge from the graph.
voidremoveVertex(VertexType v)
Remove given vertex from the graph.
voidsetNumEdgeLabels(int numLabels)
Reset the number of edge labels.
voidsetNumVertexLabels(int numLabels)
Reset number of (integer) labels.
Iterator<VertexType>successorIterator(VertexType source)
Get an iterator over the successors of this vertex; i.e., the targets of the vertex's outgoing edges.
Iterator<VertexType>vertexIterator()
Get Iterator over all vertices in the graph.

Method Detail

addVertex

public void addVertex(VertexType v)
Add given vertex to the graph. The vertex should not be part of any other graph.

Parameters: v the vertex to add

containsVertex

public boolean containsVertex(VertexType v)
Determine if the graph contains the given vertex.

Parameters: v the vertex

Returns: true if the vertex is part of the graph, false if not

createEdge

public EdgeType createEdge(VertexType source, VertexType target)
Add a new edge to the graph. Duplicate edges (with same source and target vertices) are allowed.

Parameters: source the source vertex target the target vertex

Returns: the new edge

edgeIterator

public Iterator<EdgeType> edgeIterator()
Get Iterator over all edges in the graph.

getNumEdgeLabels

public int getNumEdgeLabels()
Get the number of numeric labels that have been assigned to edges.

getNumEdges

public int getNumEdges()
Get number of edges in the graph.

getNumIncomingEdges

public int getNumIncomingEdges(VertexType vertex)
Get number of edges going into given vertex.

Parameters: vertex the vertex

Returns: number of edges going into the vertex

getNumOutgoingEdges

public int getNumOutgoingEdges(VertexType vertex)
Get number of edges going out of given vertex.

Parameters: vertex the vertex

Returns: number of edges going out of the vertex

getNumVertexLabels

public int getNumVertexLabels()
Get the number of numeric (integer) labels that have been assigned to vertices in the graph. All vertices in the graph are guaranteed to have labels in the range 0..n, where n is the value returned by this method.

getNumVertices

public int getNumVertices()
Get number of vertices in the graph.

incomingEdgeIterator

public Iterator<EdgeType> incomingEdgeIterator(VertexType target)
Get an Iterator over incoming edges to a given vertex.

Parameters: target the target vertex

Returns: an Iterator over incoming edges

lookupEdge

public EdgeType lookupEdge(VertexType source, VertexType target)
Look up an edge by source and target vertex. If multiple edges with same source and target vertex exist, one is selected arbitrarily.

Parameters: source the source vertex target the target vertex

Returns: a matching edge, or null if there is no matching edge

outgoingEdgeIterator

public Iterator<EdgeType> outgoingEdgeIterator(VertexType source)
Get an Iterator over outgoing edges from given vertex.

Parameters: source the source vertex

Returns: an Iterator over outgoing edges

predecessorIterator

public Iterator<VertexType> predecessorIterator(VertexType target)
Get an iterator over the predecessors of this vertex; i.e., the sources of the vertex's incoming edges.

Parameters: target the target vertex

Returns: an Iterator over the predecessors of the vertex

removeEdge

public void removeEdge(EdgeType e)
Remove given edge from the graph.

removeVertex

public void removeVertex(VertexType v)
Remove given vertex from the graph. Note that all edges referencing the vertex will be removed.

setNumEdgeLabels

public void setNumEdgeLabels(int numLabels)
Reset the number of edge labels.

setNumVertexLabels

public void setNumVertexLabels(int numLabels)
Reset number of (integer) labels. This might be necessary if an algorithm has assigned new labels to a graph's vertices.

successorIterator

public Iterator<VertexType> successorIterator(VertexType source)
Get an iterator over the successors of this vertex; i.e., the targets of the vertex's outgoing edges.

Parameters: source the source vertex

Returns: an Iterator over the successors of the vertex

vertexIterator

public Iterator<VertexType> vertexIterator()
Get Iterator over all vertices in the graph.
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.