I am thinking about ways to represent a graph in memory?
I was thinking to use a hash maps of hash maps so that it will behave similar to an adjacency matrix, but we can use Comparable edge labels instead of just integers.
In Breadth First Search and Dijkstra's algorithms, we have to iterate through adjacency lists and add nodes to the queue. This leads to my question:
Is iteration through a linked hash set more efficient than iteration through a regular HashSet in Java?
It seems like it would be because there are links between each node in the order that they were added so we do not have to iterate through empty bins if they exist (depending on the re-hashing ratio of the HashMap, this could be more or less). This would allow us to combine the random access behavior of the adjacency matrix with the search algorithm efficiency of the adjacency list.