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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -