private void addEdges(Set<PlanFragmentId> sourceFragments, Set<PlanFragmentId> targetFragments) { for (PlanFragmentId targetFragment : targetFragments) { for (PlanFragmentId sourceFragment : sourceFragments) { graph.addEdge(sourceFragment, targetFragment); } } } }
private Set<PlanFragmentId> processJoin(PlanNode build, PlanNode probe, PlanFragmentId currentFragmentId) { Set<PlanFragmentId> buildSources = build.accept(this, currentFragmentId); Set<PlanFragmentId> probeSources = probe.accept(this, currentFragmentId); for (PlanFragmentId buildSource : buildSources) { for (PlanFragmentId probeSource : probeSources) { graph.addEdge(buildSource, probeSource); } } return ImmutableSet.<PlanFragmentId>builder() .addAll(buildSources) .addAll(probeSources) .build(); }
private static void addEdge(DirectedGraph g, Object source, Object target, int index) { g.addEdge(source, target, new IndexedEdge(source, target, index)); }
@Override public Set<PlanFragmentId> visitRemoteSource(RemoteSourceNode node, PlanFragmentId currentFragmentId) { ImmutableSet.Builder<PlanFragmentId> sources = ImmutableSet.builder(); Set<PlanFragmentId> previousFragmentSources = ImmutableSet.of(); for (PlanFragmentId remoteFragment : node.getSourceFragmentIds()) { // this current fragment depends on the remote fragment graph.addEdge(currentFragmentId, remoteFragment); // get all sources for the remote fragment Set<PlanFragmentId> remoteFragmentSources = processFragment(remoteFragment); sources.addAll(remoteFragmentSources); // For UNION there can be multiple sources. // Link the previous source to the current source, so we only // schedule one at a time. addEdges(previousFragmentSources, remoteFragmentSources); previousFragmentSources = remoteFragmentSources; } return sources.build(); }
Set<PlanFragmentId> to = componentMembership.get(target); if (!from.equals(to)) { // the topological order iterator below doesn't include vertices that have self-edges, so don't add them componentGraph.addEdge(from, to);
graph.addEdge(e.getSourceProcessID(), e.getSinkProcessID());
private void fillDependencyGraph(DirectedGraph<String, DefaultEdge> g, String sourceVertex, Map<String, ExtensionModel> allExtensionsByNamespace) { final ExtensionModel extensionModel = allExtensionsByNamespace.get(sourceVertex); g.addVertex(sourceVertex); for (String dependencyNamespace : getDependenciesOrFail(extensionModel)) { if (allExtensionsByNamespace.containsKey(dependencyNamespace)) { g.addVertex(dependencyNamespace); g.addEdge(sourceVertex, dependencyNamespace); fillDependencyGraph(g, dependencyNamespace, allExtensionsByNamespace); } } }
/** * Goes over the {@code innerComponents} collection checking if any reference is a {@link MacroExpansionModuleModel#TNS_PREFIX}, * in which case it adds an edge to the current vertex {@code sourceOperationVertex} * * @param directedGraph graph to contain all the vertex operations and linkage with other operations * @param sourceOperationVertex current vertex we are working on * @param innerComponents collection of elements to introspect and assembly the graph with */ private void fillGraphWithTnsReferences(DirectedGraph<String, DefaultEdge> directedGraph, String sourceOperationVertex, final List<ComponentModel> innerComponents) { innerComponents.forEach(childMPComponentModel -> { if (TNS_PREFIX.equals(childMPComponentModel.getIdentifier().getNamespace())) { // we will take the current component model name, as any child of it are actually TNS child references (aka: parameters) final String targetOperationVertex = childMPComponentModel.getIdentifier().getName(); if (!directedGraph.containsVertex(targetOperationVertex)) { directedGraph.addVertex(targetOperationVertex); } directedGraph.addEdge(sourceOperationVertex, targetOperationVertex); } else { // scenario for nested scopes that might be having cyclic references to operations childMPComponentModel.getInnerComponents() .forEach(childChildMPComponentModel -> fillGraphWithTnsReferences(directedGraph, sourceOperationVertex, childMPComponentModel.getInnerComponents())); } }); }
private void addEdges(Set<PlanFragmentId> sourceFragments, Set<PlanFragmentId> targetFragments) { for (PlanFragmentId targetFragment : targetFragments) { for (PlanFragmentId sourceFragment : sourceFragments) { graph.addEdge(sourceFragment, targetFragment); } } } }
/** * <p>addEdge</p> * * @param src a V object. * @param target a V object. * @return a E object. */ protected E addEdge(V src, V target) { return graph.addEdge(src, target); }
private void addEdges(Set<PlanFragmentId> sourceFragments, Set<PlanFragmentId> targetFragments) { for (PlanFragmentId targetFragment : targetFragments) { for (PlanFragmentId sourceFragment : sourceFragments) { graph.addEdge(sourceFragment, targetFragment); } } } }
@Override protected void addUses(ATermAppl c, ATermAppl usedByC) { if( c.equals( TOP ) ) { addEquivalent( TOP, usedByC ); } else if( !c.equals( usedByC ) ) { graph.addEdge( c, usedByC ); } }
public Void visitLocalRef(RexLocalRef localRef) { for (Integer target : targets) { graph.addEdge(localRef.getIndex(), target); } return null; } }
static public <V, E> void addClique(DirectedGraph<V, E> target, Set<V> vertices) { for (V v1 : vertices) { target.addVertex(v1); for (V v2 : vertices) { target.addVertex(v2); target.addEdge(v1, v2); } } }
private void updateParentReferences(JavaClass parentClass) { for (String child : parentClass.getImports()) { JavaClass childClass = findJavaClass(child); if ((childClass != null) && !childClass.equals(parentClass)) { if (graph.containsVertex(childClass)) { graph.addEdge(parentClass, childClass); } } } }
private void replaceVertex(JavaClass newClass) { List<JavaClass> incomingEdges = getParents(newClass); graph.removeVertex(newClass); graph.addVertex(newClass); for (JavaClass each : incomingEdges) { graph.addEdge(each, newClass); } }
private void replaceVertex(JavaElement newClass) { List<Element> incomingEdges = getParents(newClass); graph.removeVertex(newClass); graph.addVertex(newClass); for (Element each : incomingEdges) { graph.addEdge(each, newClass); } }
public void addClassVariable(ClassVariable cv) { if (!this.typeGraph.containsVertex(cv)) { this.typeGraph.addVertex(cv); for (ClassVariable parent : cv.getParents()) { addClassVariable(parent); this.typeGraph.addEdge(parent, cv); } } }
public static DirectedGraph<Node, DefaultLink> asDirectedGraph(UndirectedGraph<Node, DefaultLink> undirectedGraph) { if (undirectedGraph == null) { logger.debug("graph is null."); return null; } DirectedGraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<>(DefaultLink.class); for (Node v : undirectedGraph.vertexSet()) g.addVertex(v); for (DefaultLink e: undirectedGraph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
public ReleaseGraphManager(final List<UpgradeInfo> upgradeInfos) { _directedGraph = new DefaultDirectedGraph<>( new UpgradeProcessEdgeFactory(upgradeInfos)); for (UpgradeInfo upgradeInfo : upgradeInfos) { _directedGraph.addVertex(upgradeInfo.getFromSchemaVersionString()); _directedGraph.addVertex(upgradeInfo.getToSchemaVersionString()); _directedGraph.addEdge( upgradeInfo.getFromSchemaVersionString(), upgradeInfo.getToSchemaVersionString(), new UpgradeProcessEdge(upgradeInfo)); } }