Representation of a directed Graph using Java data structures, such as Maps. In this implementation, a graph is represented by nodes or vertices, which are connected by edges with an specific weight associated. Vertices linked by an arc are called adjacent.
The Graph class includes methods for:
-
Retrieving graph info:
- Number of vertices
- List of vertices
- Number of edges
-
Retrieving vertex info:
- Whether a vertex is contained in the graph
- Indegree of a vertex
- Outdegree of a vertex
- Its list of the adjacent vertices
-
Retrieving edge info:
- Whether an edge exists between two vertices
- The weight associated to the edge
-
Manipulating graph structure:
- Insert a vertex
- Insert an edge
- Delete a vertex
- Delete an edge
-
Traversing the graph with:
- Depth-first algorithm
- Breadth-first algorithm