BFS and DFS in java and making the graph -
i'm trying make graph , breadth-first search or depth-first search through graph. how implement graph in java?
this abstract question, graph can represented in dozens different ways (different data structures).
if you're not familiar graphs recommend start with:
map<integer,arraylist<integer>>
(adjacency list) sparse graph (when number of edges close minimal number of edges), vertices keys in map, , neighbor vertices values.int[n][n]
(adjacency matrix) dense graphs (when number of edges close max number of edges), n - number of vertices.
Comments
Post a Comment