I want to create an adjacency matrix for a graph as a 2d int array. I am reading in a list of edges consisting of 2 urls so:
for example, represents a link from the index page to the contact page.
At the moment I have created a HashMap<String, Integer> and I create a new entry in the hashmap for each new url that I find and associate it with an integer which will be it's index in the adjacency matrix. So now I can use the url to get the index of that url in constant time. I want to be able to do the reverse as well, ie get the url name by searching a HashMap, which should also be in constant time.
Do I have to make 2 HashMaps for this? It seems a waste of time and memory. Is there a data structure where I can use either side as the key?
Possibly I'm doing this in a bit of a stupid way anyway, but I really want to make the adjacency list as a 2d int array because I can do calculations of pagerank etc quicker that way.
Basically I too have a requirement for Bi-directional Hash Map. One of the use case is we have is currently in our system one kind of naming say "A" namings, but some clients are interested in another naming say "B". Now for View Screens for another clients we need to map from schema(set) A to B . Alternatively if there is Data Entry Screen then in that case we need to map from B to A so the underlying system is unchanged.