{
Object currEdge = edges[j];
Object source = aGraph.getTerminal(currEdge, true);
Object target = aGraph.getTerminal(currEdge, false);
double dist = (Double) distanceMap.get(source) + costFunction.getCost(new mxCellState(view, currEdge, null));
if (dist < (Double) distanceMap.get(target))
{
distanceMap.put(target, dist);
parentMap.put(target, source);
}
//for undirected graphs, check the reverse direction too
if (!mxGraphProperties.isDirected(aGraph.getProperties(), mxGraphProperties.DEFAULT_DIRECTED))
{
dist = (Double) distanceMap.get(target) + costFunction.getCost(new mxCellState(view, currEdge, null));
if (dist < (Double) distanceMap.get(source))
{
distanceMap.put(source, dist);
parentMap.put(source, target);
}
}
}
}
for (int i = 0; i < edgeNum; i++)
{
Object currEdge = edges[i];
Object source = aGraph.getTerminal(currEdge, true);
Object target = aGraph.getTerminal(currEdge, false);
double dist = (Double) distanceMap.get(source) + costFunction.getCost(new mxCellState(view, currEdge, null));
if (dist < (Double) distanceMap.get(target))
{
throw new StructuralException("The graph contains a negative cycle, so Bellman-Ford can't be completed.");
}