Package dsa.lab10.solutions
Class DirectedGraph<Vertex,Weight>
java.lang.Object
dsa.lab10.solutions.DirectedGraph<Vertex,Weight>
- Type Parameters:
Vertex- the vertex typeWeight- the weight type (on the edges)
A directed graph implemented using adjacency lists.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty directed graph.Construct a directed graph containing the given vertices and edges. -
Method Summary
Modifier and TypeMethodDescriptionadjacencyList(Vertex source) booleanbooleanCheck if the given item is equal to any of those contained.intedges()items()Get an iterable that yields each item once.neighbours(Vertex source) intsize()Get the number of contained items.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
DirectedGraph
public DirectedGraph()Construct an empty directed graph. -
DirectedGraph
public DirectedGraph(Iterable<Vertex> vertices, Iterable<Edge<Vertex, Weight>> edges) throws IllegalArgumentExceptionConstruct a directed graph containing the given vertices and edges.- Parameters:
vertices- the verticesedges- the edges- Throws:
IllegalArgumentException- if a source/target vertex of an edge isn't in vertices, or if multiple edges are between the same pair of source and target vertices
-
-
Method Details
-
size
public int size()Description copied from interface:ContainerGet the number of contained items. -
contains
Description copied from interface:ContainerCheck if the given item is equal to any of those contained. -
contains
-
degree
- Throws:
NoSuchElementException
-
edge
-
items
Description copied from interface:ContainerGet an iterable that yields each item once. -
edges
-
adjacencyList
- Throws:
NoSuchElementException
-
neighbours
- Throws:
NoSuchElementException
-