jcommon.graph
Interface IAdjacencyList<TVertex extends IVertex<TValue>,TValue,TProcessedValue>

Type Parameters:
TVertex - Type of IVertex.
All Superinterfaces:
Iterable<IAdjacencyListPair<TVertex>>
All Known Implementing Classes:
AdjacencyList

public interface IAdjacencyList<TVertex extends IVertex<TValue>,TValue,TProcessedValue>
extends Iterable<IAdjacencyListPair<TVertex>>

An adjacency list is essentially an array of size n where A[i] is the list of out-neighbors of node i. Please see the following for a more thorough explanation: http://www.cs.cmu.edu/~avrim/451f08/lectures/lect1002.pdf Implementations of this interface must be thread safe.

See Also:
http://www.cs.cmu.edu/~avrim/451f08/lectures/lect1002.pdf

Method Summary
 int[] calculateInDegrees()
          Scans the IAdjacencyList and for each vertex it counts the number of other vertices referencing it.
 Map<TValue,TProcessedValue> createResultMap()
          Creates an instance of a Map that's properly sized for holding a mapping of values to their processed result.
 Set<TVertex> getEndingVertices()
          Provides a Set that contains vertices who have no out neighbors.
 int indexOf(TVertex vertex)
          Find the index in the IAdjacencyList at which the provided vertex argument can be found.
 boolean isEmpty()
          Determines if the adjacency list is empty.
 boolean isEndingVertex(TVertex vertex)
          Determines if the provided vertex parameter is in the set of ending vertices.
 List<TVertex> outNeighborsAt(int index)
          Gets the list of out-neighbors for a given vertex of TVertex at the provided index argument.
 List<TVertex> outNeighborsFor(TVertex vertex)
          Gets the list of out-neighbors for a given vertex of TVertex.
 IAdjacencyListPair<TVertex> pairAt(int index)
          Retrieves an instance of IAdjacencyListPair at the specified index.
 int size()
          The size of the IAdjacencyList.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

isEmpty

boolean isEmpty()
Determines if the adjacency list is empty.

Returns:
true if the adjacency list is empty; false otherwise.

outNeighborsFor

List<TVertex> outNeighborsFor(TVertex vertex)
Gets the list of out-neighbors for a given vertex of TVertex.

Parameters:
vertex - A vertex of TVertex for whom we wish to retrieve its out-neighbors.
Returns:
A list of TVertex instances who are the out-neighbors for the provided vertex argument.
See Also:
IAdjacencyListPair.getOutNeighbors()

pairAt

IAdjacencyListPair<TVertex> pairAt(int index)
Retrieves an instance of IAdjacencyListPair at the specified index.

Parameters:
index - The index in the list for which we wish to get the associated IAdjacencyListPair.
Returns:
An instance of IAdjacencyListPair if found; otherwise null.
See Also:
IAdjacencyListPair

outNeighborsAt

List<TVertex> outNeighborsAt(int index)
Gets the list of out-neighbors for a given vertex of TVertex at the provided index argument.

Parameters:
index - The index in the list for which we wish to get the associated out-neighbors.
Returns:
A list of TVertex instances who are the out-neighbors for an instance of TVertex at the specified index.
See Also:
IAdjacencyListPair.getOutNeighbors()

indexOf

int indexOf(TVertex vertex)
Find the index in the IAdjacencyList at which the provided vertex argument can be found.

Parameters:
vertex - An instance of IVertex of TVertex.
Returns:
The index in the IAdjacencyList at which the provided vertex argument can be found. -1 if the vertex cannot be found.

calculateInDegrees

int[] calculateInDegrees()
Scans the IAdjacencyList and for each vertex it counts the number of other vertices referencing it.

Returns:
An int array of size size() representing the in-degrees for each vertex.

size

int size()
The size of the IAdjacencyList. This is the same as the number of vertices in the IGraph.

Returns:
An int representing the size of the IAdjacencyList.

getEndingVertices

Set<TVertex> getEndingVertices()
Provides a Set that contains vertices who have no out neighbors.

Returns:
A Set containing vertices with no out neighbors.

isEndingVertex

boolean isEndingVertex(TVertex vertex)
Determines if the provided vertex parameter is in the set of ending vertices.

Parameters:
vertex - The vertex for whom you wish to test for set membership.
Returns:
true if the vertex is in the set of ending vertices; false otherwise.
See Also:
getEndingVertices()

createResultMap

Map<TValue,TProcessedValue> createResultMap()
Creates an instance of a Map that's properly sized for holding a mapping of values to their processed result.

Returns:
An instance of Map mapping values to their processed result.


Copyright © 2012-2013. All Rights Reserved.