dec1.getFunctionallyGroundedNodes());
Set<FunctionallyGroundedNode> fgNodes2 = new HashSet<FunctionallyGroundedNode>(
dec2.getFunctionallyGroundedNodes());
// commonFgNodes = new HashSet<FunctionallyGroundedNode>();
for (Iterator iter = fgNodes1.iterator(); iter.hasNext();) {
FunctionallyGroundedNode current = (FunctionallyGroundedNode) iter
.next();
if (fgNodes2.contains(current)) {
// commonFgNodes.add(current);
iter.remove();
fgNodes2.remove(current);
}
}
Map<FunctionallyGroundedNode, CrossGraphFgNode> fgNodes12CrossGraphFgNodes = new HashMap<FunctionallyGroundedNode, CrossGraphFgNode>();
Map<FunctionallyGroundedNode, CrossGraphFgNode> fgNodes22CrossGraphFgNodes = new HashMap<FunctionallyGroundedNode, CrossGraphFgNode>();
for (Iterator iter = fgNodes1.iterator(); iter.hasNext();) {
FunctionallyGroundedNode fgnode1 = (FunctionallyGroundedNode) iter
.next();
CrossGraphFgNode matching = new CrossGraphFgNode();
matching.getNodesIn1().add(fgnode1);
boolean fgNodeInCrossGraph = false;
for (Iterator iterator = fgnode1.getGroundingMolecules().iterator(); iterator
.hasNext();) {
NonTerminalMolecule current = (NonTerminalMolecule) iterator
.next();
FunctionallyGroundedNode fgnode2 = getFgNodeWith(fgNodes2,
current);
if (fgnode2 != null) {
fgNodeInCrossGraph = true;
matching.getNodesIn2().add(fgnode2);
fgNodes22CrossGraphFgNodes.put(fgnode2, matching);
}
}
if (!fgNodeInCrossGraph) {
fgNodesOnlyIn1.add(fgnode1);
} else {
fgNodes12CrossGraphFgNodes.put(fgnode1, matching);
//TODO ensure later finalization
crossGraphFgNodes.add(matching);
}
}
for (Iterator<FunctionallyGroundedNode> iter = fgNodes2.iterator(); iter
.hasNext();) {
FunctionallyGroundedNode fgnode2 = iter.next();
boolean fgNodeInCrossGraph = false;
for (Iterator iterator = fgnode2.getGroundingMolecules().iterator(); iterator
.hasNext();) {
NonTerminalMolecule current = (NonTerminalMolecule) iterator
.next();
FunctionallyGroundedNode fgnode1 = getFgNodeWith(fgNodes1,
current);
if (fgnode1 != null) {
fgNodeInCrossGraph = true;
// check if there is already an OverlappingNodes with
// fgnode1 and 2
CrossGraphFgNode crossNodeWith2 = fgNodes22CrossGraphFgNodes
.get(fgnode2);
if (crossNodeWith2 == null) {
// graph is not lean
for (NonTerminalMolecule molecule : fgnode2
.getGroundingMolecules()) {
FunctionallyGroundedNode fgnode2alt = getFgNodeWith(
fgNodes2, molecule);
if ((fgnode2alt != null)
&& (!fgnode2.equals(fgnode2alt))) {
crossNodeWith2 = fgNodes22CrossGraphFgNodes
.get(fgnode2alt);