/** * Checks if there is a path from source to destination * @param sourceNode source * @param destNode destination * @return true if there is a path from source to destination */ private static boolean existsPath(NodeImpl sourceNode, NodeImpl destNode) { if (sourceNode.equals(destNode)) { return true; } if (sourceNode.hasOutgoingTransitions()) { for (Transition t : sourceNode.getOutgoingTransitions()) { if (existsPath((NodeImpl) t.getDestination(), destNode)) { return true; } } } return false; }
/** * Fill the path and transitions fields of the CycleObject c. * @param c cycle object to fill * @param sourceNode source node of the path * @param destNode destination of the path * @return */ private static boolean fillCycleObject(CycleObject c, NodeImpl sourceNode, NodeImpl destNode) { if (sourceNode.equals(destNode)) { c.path.add(sourceNode.getName()); return true; } if (sourceNode.hasOutgoingTransitions()) { boolean res = false; for (Transition t : sourceNode.getOutgoingTransitions()) { if (fillCycleObject(c, (NodeImpl) t.getDestination(), destNode)) { c.path.add(sourceNode.getName()); MyTransition myT = new MyTransition(); myT.fromNode = t.getSource().getName(); myT.toNode = t.getDestination().getName(); c.transitions.add(myT); res = true; } } return res; } return false; }
for (String nodeName : c.path) { NodeImpl sourceNode = inProcess.getNode(nodeName); if (sourceNode.hasOutgoingTransitions()) {