
Graph
Chapter 54
Adjacency Matrix Data Structure
package graph
GraphRepresentation<V,E extends Edge<V>> implements Iterable<V>
↑
AdjacencyMatrixRepresentation<V,E extends Edge<V>> implements Iterable<V>
Uses:
Java primitive array is used for the matrix.
DoublyLinkedList (Chapter 16) is used for the edge list for multi-edges.
Strengths: When the graph is dense, the adjacency matrix is the most space efficient representa-
tion, particularly when it is not a multigraph. If desired, the space usage can be reduced even further
for an undirected graph. Another advantage of an adjacency matrix is that it takes constant time to
determine if there is an edge from ...