E
- the edge type of the graphpublic final class AdjacencyList<E extends DirectedEdge<?,E>> extends java.util.ArrayList<EdgeList<E>>
Constructor and Description |
---|
AdjacencyList(int count)
Creates a new AdjacenyList for a graph with count vertices
|
Modifier and Type | Method and Description |
---|---|
void |
append(int vertex,
E edge)
Appends an edge to the adjacency of a given vertex.
|
EdgeList<E> |
get(int vertex)
Returns an
EdgeList of edges for a given vertex. |
static <T,E extends DirectedEdge<T,E>> |
of(Graph<E> g)
Takes a
Graph graph and transforms it into an AdjacencyList |
static <T,E extends DirectedEdge<T,E>> |
of(int vertices,
java.lang.Iterable<? extends E> edges)
Takes a graph given by the number of vertices and an
Iterable of edges and transforms it into an AdjacencyList |
java.lang.String |
toString() |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
public AdjacencyList(int count)
count
- the number of vertices in the AdjacencyListpublic static <T,E extends DirectedEdge<T,E>> AdjacencyList<E> of(Graph<E> g)
Graph
graph and transforms it into an AdjacencyListT
- the weight type of the edges in the graphE
- the edge type of the edges in the graphg
- the Graph
to be transformedpublic static <T,E extends DirectedEdge<T,E>> AdjacencyList<E> of(int vertices, java.lang.Iterable<? extends E> edges)
Iterable
of edges and transforms it into an AdjacencyListT
- the weight type of the edges in the graphE
- the edge type of the edges in the graphvertices
- the number of verticesedges
- an Iterable
of edgespublic EdgeList<E> get(int vertex)
EdgeList
of edges for a given vertex.get
in interface java.util.List<EdgeList<E extends DirectedEdge<?,E>>>
get
in class java.util.ArrayList<EdgeList<E extends DirectedEdge<?,E>>>
vertex
- specifies the vertexEdgeList
of edges for the given vertexpublic void append(int vertex, E edge)
vertex
- specifies the vertexedge
- the edge to be appendedpublic java.lang.String toString()
toString
in class java.util.AbstractCollection<EdgeList<E extends DirectedEdge<?,E>>>