public static void convert(Op op, DirectedAcyclicGraph<Op, DefaultEdge> result) { List<Op> children = OpUtils.getSubOps(op); for(Op child : children) { result.addVertex(child); result.addEdge(op, child); convert(child, result); } }
private static Work[] getSetVariableValuesOrdered(BaseElement element) { Work[] values = setVariablePropertyCache.get(element); if (values == null) { String[] expressions = DemoModelInstrumentator.readCamundaPropertyMulti(element, "simulateSetVariable").toArray(new String[] {}); values = new Work[expressions.length]; DirectedAcyclicGraph<Work, Object> graph = new DirectedAcyclicGraph<>(Object.class); for (int i = 0; i < expressions.length; i++) { values[i] = new Work(expressions[i]); graph.addVertex(values[i]); } for (Work currentWork : values) { for (Work otherWork : values) { if (currentWork.valueExpression.matches(".*\\W" + Pattern.quote(otherWork.variableExpression) + "\\W.*")) { try { graph.addEdge(otherWork, currentWork); } catch (IllegalArgumentException e) { LOG.warn("Possible cycle in simulateSetVariable-dependencies detected when checking '{}'", currentWork.valueExpression); } } } } int i = 0; for (Iterator<Work> iterator = graph.iterator(); iterator.hasNext();) { Work next = iterator.next(); values[i++] = next; } setVariablePropertyCache.put(element, values); } return values; }
public static void convert(Op op, DirectedAcyclicGraph<Op, DefaultEdge> result) { List<Op> children = OpUtils.getSubOps(op); for(Op child : children) { result.addVertex(child); result.addEdge(op, child); convert(child, result); } }
/** * Computes the transitive closure of a directed acyclic graph in $O(nm)$ * * @param graph - Graph to compute transitive closure for. * @param <V> the graph vertex type * @param <E> the graph edge type */ public <V, E> void closeDirectedAcyclicGraph(DirectedAcyclicGraph<V, E> graph) { Deque<V> orderedVertices = new ArrayDeque<>(graph.vertexSet().size()); new TopologicalOrderIterator<>(graph).forEachRemaining(orderedVertices::addFirst); for (V vertex : orderedVertices) { for (V successor : Graphs.successorListOf(graph, vertex)) { for (V closureVertex : Graphs.successorListOf(graph, successor)) { graph.addEdge(vertex, closureVertex); } } } }