I have the following multiMap:
1st: [3=>[4,5]]
2nd: [2=>[3]]
3rd: [0=>[2]]
4th: [5=>[1]]
5th: [4=>[1]]
I would like to get the sequence out of it such as:
0->2->3->[4,5]->1
Is it possible?
This is what I have tried, but doesn't seem to work correctly:
// the starting point is given from the start.
Collection<String> col = new HashSet<String>();
col.add("0");
buildPath2(myMultimap, col, result2);
static void buildPath2(Multimap<String, String> path, Collection<String> token, List<Collection<String>> result2) {
if (token != null) {
result2.add(token);
Collection<String> c = null;
for (String elem: token){
c = path.get(elem);
}
buildPath2(path, c, result2);
}
}