You are viewing a single comment's thread. Return to all comments →
That is also fine, but 2 lists would be probably more readable. I would prefer this:
adj.get(first).add(second)
on this:
adj[first].add(second)
less prone to mistakes.
Anyway, as others have said, there many ways to represent graphs.
Seems like cookies are disabled on this browser, please enable them to open this website
BFS: Shortest Reach in a Graph
You are viewing a single comment's thread. Return to all comments →
That is also fine, but 2 lists would be probably more readable. I would prefer this:
on this:
less prone to mistakes.
Anyway, as others have said, there many ways to represent graphs.