Implement Graph Using Map - Java | Algorithms
In this article, we will implement the Graph represented by Adjacency List using the HashMap data structure. Use Hash Maps: We will use two maps. The first map for storing the vertices and edges. Second map for storing the index for each vertex. the second map will be used in traversing the graph to avoid going in loops. (used by the visited array in case of DFS or BFS ).
Post to Tumblr