* @param elem element containing the difference.
*/
static public void loadDiff(PatchGraph graphPatcher, Element elem)
{
Configuration config = Configuration.getDefaultConfiguration().copy();config.setLearnerCloneGraph(false);
LearnerGraphND gr = new LearnerGraphND(config);AbstractPersistence.loadGraph(getGraphElement(elem, StatechumXML.gdRemoved.toString(),false,true),gr);
//System.out.println("removed: "+gr.transitionMatrix.keySet());
for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entry:gr.transitionMatrix.entrySet())
for(Entry<Label,List<CmpVertex>> transition:entry.getValue().entrySet())
for(CmpVertex target:gr.getTargets(transition.getValue()))
graphPatcher.removeTransition(entry.getKey(), transition.getKey(), target);
for(Entry<CmpVertex,Map<CmpVertex,JUConstants.PAIRCOMPATIBILITY>> incompatibles:gr.pairCompatibility.compatibility.entrySet())
for(CmpVertex target:incompatibles.getValue().keySet())
graphPatcher.removeFromCompatibility(incompatibles.getKey(), target);
AbstractPersistence.loadGraph(getGraphElement(elem, StatechumXML.gdAdded.toString(),false,true),gr);
//System.out.println("added: "+gr.transitionMatrix.keySet()+"\n with incompatibles : "+gr.pairCompatibility.keySet());
for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entry:gr.transitionMatrix.entrySet())
{
if (entry.getValue().isEmpty())
graphPatcher.addVertex(entry.getKey());
else
for(Entry<Label,List<CmpVertex>> transition:entry.getValue().entrySet())
for(CmpVertex target:gr.getTargets(transition.getValue()))
graphPatcher.addTransition(entry.getKey(), transition.getKey(), target);
}
for(Entry<CmpVertex,Map<CmpVertex,JUConstants.PAIRCOMPATIBILITY>> incompatibles:gr.pairCompatibility.compatibility.entrySet())
for(Entry<CmpVertex,JUConstants.PAIRCOMPATIBILITY> targetEntry:incompatibles.getValue().entrySet())
graphPatcher.addToCompatibility(incompatibles.getKey(), targetEntry.getKey(), targetEntry.getValue());
NodeList relabellingElementList= StatechumXML.getChildWithTag(elem,StatechumXML.gdRelabelling.toString());
if (relabellingElementList.getLength() > 0)
{// load the relabelling if present.
getGraphElement(elem, StatechumXML.gdRelabelling.toString(),true,false);// check that XML structure is consistent and there are pairs stored - will throw otherwise
Element relabellingElement = (Element)relabellingElementList.item(0);
NodeList children = relabellingElement.getChildNodes();
for(int childNum=0;childNum<children.getLength();++childNum)
if (children.item(childNum).getNodeType() == Node.ELEMENT_NODE)
{
PairScore pair=ProgressDecorator.readPair(gr, (Element)children.item(childNum));
graphPatcher.addRelabelling(pair.getQ().getID(), pair.getR().getID());
}
}
graphPatcher.setInitial(gr.getInit());
}