}
// Makes a copy of the current path to enable back tracking if no solution is found.
ArrayList<IConnector> subPath = (ArrayList<IConnector>) memoPoint.path.clone();
subPath.add(connector);
INode connectorSource = connector.getSource();
INode connectorTarget = connector.getTarget();
if (!connectorTarget.equals(src) && !connectorTarget.equals(memoPoint.src)) {
// -- VERSION 2: Check for cycle --
int cycleStart = -1;
int cycleEnd = -1;
ArrayStack<INode> compressedSubPath = (ArrayStack<INode>) memoPoint.compressedPath.clone(); // using only nodes (No edge) {startNode, nextNode, nextNode, ..., endNode}
if (compressedSubPath.isEmpty()) {
// Add startNode
compressedSubPath.push(connectorSource);
compressedSubPath.push(connectorTarget);
} else if (compressedSubPath.contains(connectorTarget)) {
// CYCLE FOUND
cycleStart = compressedSubPath.indexOf(connectorTarget);
cycleEnd = compressedSubPath.size() - 1;
} else {
// Add nextNode
compressedSubPath.push(connectorTarget);
}
if (cycleStart != -1 && cycleEnd != -1) {
ArrayList<IConnector> cyclePath = new ArrayList<IConnector>(cycleEnd - cycleStart + 1);
// mark cycle
for (int i = cycleStart; i <= cycleEnd; i++) {
IConnector inCycleConnector = subPath.get(i);
inCycleConnector.setInCycle(true);
cyclePath.add(inCycleConnector);
}
Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Cycle found : " + cyclePath
+ " as subset of path : " + subPath);
LOGGER.log(status);
continue;
}
// -- VERSION 2 : End cycle detection as subset of path --
if (connectorTarget.equals(dst)) {
// Path from src to dst is found
allPath.add(subPath);
continue;
} else {
// Simulate recursive function call.