3

BiMap do have inverse method but I am not sure it is a right collection to use for the problem. Can someone please suggest alternative approach or collection/method? An example would be helpful.

Thanks in advance. Prakash

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
Prakash Gautam
  • 502
  • 4
  • 13
  • To accept the answer, you're probably going to have to merge the account you used to ask your question and your new account, Prakash Gautam. You should not post answers with questions or comments. – dandan78 Apr 16 '11 at 12:10

1 Answers1

1

Could you show a simple code sample of how you would use such a data structure?

Should keys / values be unique? In this case, BiMap sounds about right.

If keys / values are not unique, you want some kind of "BiMultimap" (also called a "graph"), as discussed in this Guava discussion thread. Google has not (yet?) open sourced their own internal BiMultimap.

If you want a graph, you might want to look at JUNG or Flexigraph, as discussed in the thread.

Etienne Neveu
  • 12,604
  • 9
  • 36
  • 59
  • Hi, The idea is to build a powerful framework that can compute deep cause/effect relationships (8-10 levels down). Graph data structure is involved here and direct or inverse relationship between vertices determines cause and effect where a vertex can only be a cause or effect. Both vertices cannot be a cause or an effect at a given instance. And vertices should be able to scale to 200K. The relationship computation would then be done in the cloud. I hope I am clear and thanks in advance for any help. Prakah – Prakash Gautam Apr 08 '11 at 04:37
  • 1
    200K don't sound much, and assuming a sparse graph, it should fit in memory. Long short, but if your relation is transitive (it sure sounds like one!) _and_ you never or almost never remove edges, but only add, you should check this project (shameless plug): http://code.google.com/p/transitivity-utils/ – Dimitris Andreou Apr 11 '11 at 16:11
  • Dimitris, you should have posted this in a separate answer, since I think it might answer prakash's needs better than mine ;) transitivity-utils looks interesting, BTW. – Etienne Neveu Apr 11 '11 at 23:18