As the title says.. What is the most efficient way to store a connected graph in java?
For example lets say I have multiple locations connecting to each other in various ways and I have to traverse through the graph to see if it’s connected.. any help/comment would be helpful thanks!
One often used representation is a matrix (two dimensional array) indexed by all the nodes in the graph, where
M[i,j] == trueif there is a directed edge from nodeitoj. A variation on the theme is to store the length / weight of the edge between the two nodes (where a missing edge may be represented by the value -1).