Q:

how can I compare HashMaps with different keys?

I have a clustering algorithm storing the clusters in HashMap<String, ArrayList<String>>.
I need to compare it with the ground truth which is stored in another HashMap<String, ArrayList<String>>.
The keys are not the same, because the array is created by incremental clustering, so I was wondering how can I compare the original clusters with the generated ones.
I'm using NMI and BCUBED as clustering evaluation measures, but my problem is how to refer to the same cluster (ArrayList) if they have different keys..
Any ideas?

A:

I'm not 100% clear on how your class is set up and how the HashMap<String, ArrayList<String>> is really meant to work, but my inclination is that you should have a Hash of your keys.  So as you're assigning clusters you could do something like this.
Original Data:  
Hashmap<String, ArrayList<String>> = key: Array Of Original Data

You would store what is in each cluster as a function of:
HashMap<String, ArrayList<String>> = Cluster Key: Array of Original Data Keys

That would give you a mechanism to cycle through the objects that are in each cluster and still maintain the state of the original object, does that make sense?  You'd ultimately then be able to write something akin to:
for(String clusterKey : clusterMap.keySet()){
    for(String itemKey : clusterMap.get(clusterKey)){
       calculateDistance(centroid, originalMap.get(itemKey);
    }
}

That is a gross oversimplification, but should get you going in the right direction.
edit
I also assumer there is a HashMap of the centroids to the clusters themselves.  So it the calculateDistance() method could be rewritted as calculateDistance(centroidMap.get(clusterKey), originalMap.get(itemKey));

