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

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -