int destValue = (int) costFunction.getCost(new mxCellState(view, aGraph.getTerminal(edge, false), null));
if (aGraph.getTerminal(edge, false) != null || aGraph.getTerminal(edge, true) != null)
{
Object[] cells = model.cloneCells(aGraph.getChildCells(graph.getDefaultParent(), true, true), true);
mxGraphModel modelCopy = new mxGraphModel();
mxGraph graphCopy = new mxGraph(modelCopy);
graphCopy.addCells(cells);
mxAnalysisGraph aGraphCopy = new mxAnalysisGraph();
aGraphCopy.setGraph(graphCopy);
aGraphCopy.setGenerator(aGraph.getGenerator());
aGraphCopy.setProperties(aGraph.getProperties());
Object[] edges = aGraphCopy.getChildEdges(aGraphCopy.getGraph().getDefaultParent());
Object currEdge = edges[0];
mxCostFunction costFunctionCopy = aGraphCopy.getGenerator().getCostFunction();
mxGraphView viewCopy = graphCopy.getView();
int currSrcValue = (int) costFunctionCopy.getCost(new mxCellState(viewCopy, aGraphCopy.getTerminal(currEdge, true), null));
int currDestValue = (int) costFunctionCopy.getCost(new mxCellState(viewCopy, aGraphCopy.getTerminal(currEdge, false), null));
int i = 0;
while (currSrcValue != srcValue || currDestValue != destValue)
{
i++;
currEdge = edges[i];
currSrcValue = Integer.parseInt((String) modelCopy.getValue(aGraphCopy.getTerminal(currEdge, true)));
currDestValue = Integer.parseInt((String) modelCopy.getValue(aGraphCopy.getTerminal(currEdge, false)));
}
graphCopy.removeCells(new Object[] { currEdge }, true);
Object[][] oldComponents = getGraphComponents(aGraph);
Object[][] newComponents = getGraphComponents(aGraphCopy);