private void weightGraphGenerateHelper(TopologySpec topologySpec) { try { Map<ServiceNode, ServiceNode> capabilities = topologySpec.getSpecExecutor().getCapabilities().get(); for (Map.Entry<ServiceNode, ServiceNode> capability : capabilities.entrySet()) { BaseServiceNodeImpl sourceNode = new BaseServiceNodeImpl(capability.getKey().getNodeName()); BaseServiceNodeImpl targetNode = new BaseServiceNodeImpl(capability.getValue().getNodeName()); if (!weightedGraph.containsVertex(sourceNode)) { weightedGraph.addVertex(sourceNode); } if (!weightedGraph.containsVertex(targetNode)) { weightedGraph.addVertex(targetNode); } FlowEdge flowEdge = new LoadBasedFlowEdgeImpl(sourceNode, targetNode, defaultFlowEdgeProps, topologySpec.getSpecExecutor()); // In Multi-Graph if flowEdge existed, just skip it. if (!weightedGraph.containsEdge(flowEdge)) { weightedGraph.addEdge(sourceNode, targetNode, flowEdge); } } } catch (InterruptedException | ExecutionException e) { Instrumented.markMeter(this.flowCompilationFailedMeter); throw new RuntimeException("Cannot determine topology capabilities", e); } }
public ConvertFunction addEdge(Representation startVertex, Representation endVertex, ConvertFunction convertFunction) { this.mConvertFunctionFactory.put(startVertex, endVertex, convertFunction); this.mGraph.addVertex(startVertex); this.mGraph.addVertex(endVertex); return this.mGraph.addEdge(startVertex, endVertex); }
public static DirectedWeightedMultigraph<Node, DefaultLink> asDefaultGraph(DirectedWeightedMultigraph<Node, LabeledLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } DirectedWeightedMultigraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<>(DefaultLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
public static DirectedWeightedMultigraph<Node, LabeledLink> asLabeledGraph(DirectedWeightedMultigraph<Node, DefaultLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } DirectedWeightedMultigraph<Node, LabeledLink> g = new DirectedWeightedMultigraph<>(LabeledLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) if (e instanceof LabeledLink) g.addEdge(e.getSource(), e.getTarget(), (LabeledLink)e); return g; }
this.graph.addEdge(source, target, link);
target = idToNodes.get(LinkIdFactory.getLinkTargetId(l.getId())); if (source != null && target != null) { graph.addEdge(source, target, l); if (weight[0] != null) graph.setEdgeWeight(l, weight[0].doubleValue());
private void weightGraphGenerateHelper(TopologySpec topologySpec) { try { Map<ServiceNode, ServiceNode> capabilities = topologySpec.getSpecExecutor().getCapabilities().get(); for (Map.Entry<ServiceNode, ServiceNode> capability : capabilities.entrySet()) { BaseServiceNodeImpl sourceNode = new BaseServiceNodeImpl(capability.getKey().getNodeName()); BaseServiceNodeImpl targetNode = new BaseServiceNodeImpl(capability.getValue().getNodeName()); if (!weightedGraph.containsVertex(sourceNode)) { weightedGraph.addVertex(sourceNode); } if (!weightedGraph.containsVertex(targetNode)) { weightedGraph.addVertex(targetNode); } FlowEdge flowEdge = new LoadBasedFlowEdgeImpl(sourceNode, targetNode, defaultFlowEdgeProps, topologySpec.getSpecExecutor()); // In Multi-Graph if flowEdge existed, just skip it. if (!weightedGraph.containsEdge(flowEdge)) { weightedGraph.addEdge(sourceNode, targetNode, flowEdge); } } } catch (InterruptedException | ExecutionException e) { Instrumented.markMeter(this.flowCompilationFailedMeter); throw new RuntimeException("Cannot determine topology capabilities", e); } }
private void mergeModels(DirectedWeightedMultigraph<Node, LabeledLink> model1, DirectedWeightedMultigraph<Node, LabeledLink> model2) { for(Node n : model1.vertexSet()) { model2.addVertex(n); for(LabeledLink link : model1.incomingEdgesOf(n)) { model2.addVertex(link.getSource()); model2.addVertex(link.getTarget()); model2.addEdge(link.getSource(), link.getTarget(), link); } } this.models.remove(model1); } }
tree.addEdge(target, source, reverseLink); tree.setEdgeWeight(reverseLink, inLink.getWeight());
private void addLinks(Set<LabeledLink> links) { if (links == null) return; for (LabeledLink link : links) { if (!this.tree.containsEdge(link) && this.tree.containsVertex(link.getSource()) && this.tree.containsVertex(link.getTarget())) { this.tree.addEdge(link.getSource(), link.getTarget(), link); } } }
nodeModel.addEdge(source, target, link);
tree.addVertex(stm.getTarget()); if (tree.vertexSet().contains(stm.getSource())) { tree.addEdge(stm.getSource(), stm.getTarget(), dataPropertyLink); tree.setEdgeWeight(dataPropertyLink, stm.getLink().getWeight()); } else {
tree.addEdge(link.getSource(), link.getTarget(), newLink); tree.setEdgeWeight(newLink, link.getWeight()); if (allowedChangingGraph) this.graphBuilder.addLink(link.getSource(), link.getTarget(), newLink);
tree.addEdge(source, target, newLink); tree.setEdgeWeight(newLink, l.getWeight());
private void addForcedLinks() { Set<LabeledLink> forcedLinks = getLinksByStatus(LinkStatus.ForcedByUser); if (forcedLinks != null) for (LabeledLink link : forcedLinks) { if (!this.steinerTree.containsEdge(link)) { if (!this.steinerTree.containsVertex(link.getSource())) { this.steinerTree.addVertex(link.getSource()); } if (!this.steinerTree.containsVertex(link.getTarget())) { this.steinerTree.addVertex(link.getTarget()); } this.steinerTree.addEdge(link.getSource(), link.getTarget(), link); } } }