fragments.forEach(fragment -> graph.addVertex(fragment.getId()));
graph.addVertex(v);
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 extractOperationExtension(HasOperationDeclarer declarer, ComponentModel operationModel, DirectedGraph<String, DefaultEdge> directedGraph, XmlDslModel xmlDslModel) { String operationName = operationModel.getNameAttribute(); OperationDeclarer operationDeclarer = declarer.withOperation(operationName); ComponentModel bodyComponentModel = operationModel.getInnerComponents() .stream() .filter(child -> child.getIdentifier().equals(OPERATION_BODY_IDENTIFIER)).findFirst() .orElseThrow(() -> new IllegalArgumentException(format("The operation '%s' is missing the <body> statement", operationName))); directedGraph.addVertex(operationName); fillGraphWithTnsReferences(directedGraph, operationName, bodyComponentModel.getInnerComponents()); operationDeclarer.withModelProperty(new OperationComponentModelModelProperty(operationModel, bodyComponentModel)); operationDeclarer.describedAs(getDescription(operationModel)); operationDeclarer.getDeclaration().setDisplayModel(getDisplayModel(operationModel)); extractOperationParameters(operationDeclarer, operationModel); extractOutputType(operationDeclarer.withOutput(), OPERATION_OUTPUT_IDENTIFIER, operationModel, getDeclarationOutputFor(operationName)); extractOutputType(operationDeclarer.withOutputAttributes(), OPERATION_OUTPUT_ATTRIBUTES_IDENTIFIER, operationModel, getDeclarationOutputAttributesFor(operationName)); declareErrorModels(operationDeclarer, xmlDslModel, operationName, operationModel); }
/** * Add all of the vertices to the graph without any edges. If the the graph * already contains any one of the vertices, that vertex is not added. * @param graph graph to be mutated * @param vertices vertices to add */ public static <V> void addAllVertices(DirectedGraph<V, DefaultEdge> graph, Set<V> vertices) { // add all of the new vertices to prep for linking for (V vertex : vertices) { graph.addVertex(vertex); } }
/** * The constructor. * * @param initialState * the state to start from. */ public StateFlowGraph(StateVertex initialState) { this(); sfg.addVertex(initialState); }
/** * <p>addVertex</p> * * @param v a V object. * @return a boolean. */ protected boolean addVertex(V v) { return graph.addVertex(v); }
public boolean addInfoVertex(InfoVertex<T, C> vertex) { Validate.notNull(vertex); final boolean added = this.graph.addVertex(vertex); if (added) { logger.trace(MessageFormat.format("Added ({0}).", vertex.toString())); } return added; }
private void addToGraph(JavaClass newClass) { if (!graph.addVertex(newClass)) { replaceVertex(newClass); } }
private BaseRunRequirements(AddOn addOn) { this.addOn = addOn; dependencyTree = new DefaultDirectedGraph<>(DefaultEdge.class); dependencyTree.addVertex(addOn); runnable = true; issueDetails = Collections.emptyList(); }
private void addToGraph(JavaElement newClass) { if (!graph.addVertex(newClass)) { replaceVertex(newClass); } }
private void processMenu(Menu menu) { graph = new DefaultDirectedGraph<String, DefaultEdge>(DefaultEdge.class); graph.addVertex(rootNode); logger.trace("Added Root: "+rootNode); for(MenuItem mi : menu.getMenuItem()) { processMenuItem(rootNode,mi); } }
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 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)); } }
public static DirectedGraph<Node, LabeledEdge> asJGraphT(Query query) { QueryUtils utils = new QueryUtils(); Set<Triple> tps = utils.extractTriplePattern(query); DirectedGraph<Node, LabeledEdge> g = new DefaultDirectedGraph<>(LabeledEdge.class); tps.forEach(tp -> { g.addVertex(tp.getSubject()); g.addVertex(tp.getObject()); g.addEdge(tp.getSubject(), tp.getObject(), new LabeledEdge(tp.getSubject(), tp.getObject(), tp.getPredicate())); }); return g; }