*/
public static Map<Node, Node> getValidMapping(Graph g1, Graph g2) {
// maps a triple-pattern to Collection[2]
Map<TrivialTriplePattern, Set[]> patternTripleMap = new HashMap<TrivialTriplePattern, Set[]>();
for (Iterator iter = g1.iterator(); iter.hasNext();) {
Triple current = (Triple) iter.next();
TrivialTriplePattern pattern = new TrivialTriplePattern(current);
Set[] matchings = patternTripleMap.get(pattern);
if (matchings == null) {
matchings = new HashSet[2];
matchings[0] = new HashSet();
matchings[1] = new HashSet();
patternTripleMap.put(pattern, matchings);
}
matchings[0].add(current);
}
for (Iterator iter = g2.iterator(); iter.hasNext();) {
Triple current = (Triple) iter.next();
TrivialTriplePattern pattern = new TrivialTriplePattern(current);
Set[] matchings = patternTripleMap.get(pattern);
if (matchings == null) {
continue;
}