Package dsa.lab10.exercises
Class DirectedGraph<Vertex,Weight>
java.lang.Object
dsa.lab10.exercises.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) boolean
boolean
Check if the given item is equal to any of those contained.int
edges()
items()
Get an iterable that yields each item once.neighbours
(Vertex source) int
size()
Get the number of contained items.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:Container
Get the number of contained items. -
contains
Description copied from interface:Container
Check if the given item is equal to any of those contained. -
contains
-
degree
- Throws:
NoSuchElementException
-
edge
-
items
Description copied from interface:Container
Get an iterable that yields each item once. -
edges
-
adjacencyList
- Throws:
NoSuchElementException
-
neighbours
- Throws:
NoSuchElementException
-