Package it.unimi.di.prog2.h24.digraph
Class AdjacencyMatrixDiGraph<T>
java.lang.Object
it.unimi.di.prog2.h24.digraph.AdjacencyMatrixDiGraph<T>
- Type Parameters:
T
- the type of the nodes of the graph.
- All Implemented Interfaces:
DiGraph<T>
A partially mutable directed graph implementation based on an adjacency matrix.
This implementation is partially mutable: the set of nodes is fixed at construction time, while arcs can be added at any time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean[][]
The adjacency matrix.The nodes of the graph, in some order. -
Constructor Summary
ConstructorsConstructorDescriptionAdjacencyMatrixDiGraph
(DiGraph<? extends T> graph) Creates a graph with the same nodes and arcs of the given graph.AdjacencyMatrixDiGraph
(Set<? extends T> nodes) Creates a graph with the given nodes. -
Method Summary
-
Field Details
-
nodes
The nodes of the graph, in some order. -
adjacencyMatrix
private final boolean[][] adjacencyMatrixThe adjacency matrix.
-
-
Constructor Details
-
AdjacencyMatrixDiGraph
Creates a graph with the given nodes.- Parameters:
nodes
- the nodes of the graph.- Throws:
NullPointerException
- ifnodes
is, or contains,null
.
-
AdjacencyMatrixDiGraph
Creates a graph with the same nodes and arcs of the given graph.- Parameters:
graph
- the graph to copy.- Throws:
NullPointerException
- ifgraph
isnull
.
-
-
Method Details
-
nodes
Description copied from interface:DiGraph
Returns the graph nodes. -
addNode
Description copied from interface:DiGraph
Adds a node to this graph. -
addArc
Description copied from interface:DiGraph
Adds an arc to this graph.It the source, or destination, node are not present in the graph, they are also added.
-
outgoing
Description copied from interface:DiGraph
Returns the set of outgoing nodes of a given node.
-