public void addEdge(Node s, Node t, double score) { DefaultWeightedEdge e = graph.addEdge(s, t); double sc = getNodeScore(t) + score; graph.setEdgeWeight(e, sc); }
public ShortestPathInference() { graph = new SimpleDirectedWeightedGraph<Node, DefaultWeightedEdge>( DefaultWeightedEdge.class); }
public void addNode(Node node, double score) { graph.addVertex(node); if (score != 0) scores.put(node, score); }
public void updateEdgeWeight(Node s, Node t, double score) { DefaultWeightedEdge e = graph.getEdge(s, t); double sc = getNodeScore(t) + score; graph.setEdgeWeight(e, sc); }
final SimpleDirectedWeightedGraph< V, DefaultWeightedEdge > copy = new SimpleDirectedWeightedGraph< >( DefaultWeightedEdge.class ); final Set< Spot > spots = graph.vertexSet(); function.compute( spot, vertex ); map.put( spot, vertex ); copy.addVertex( vertex ); final DefaultWeightedEdge newEdge = copy.addEdge( map.get( graph.getEdgeSource( edge ) ), map.get( graph.getEdgeTarget( edge ) ) ); copy.setEdgeWeight( newEdge, graph.getEdgeWeight( edge ) );
public IaaSTaxonomy() { iaasTaxonomie = new SimpleDirectedWeightedGraph<>(DefaultWeightedEdge.class); properties = new Properties(); try { elasticQueue = properties.getProperty("nodeElasticQueue"); iaasTaxonomie.addVertex(iaas); iaasTaxonomie.addVertex(elasticInfrastructure); iaasTaxonomie.addVertex(envBasedAv); iaasTaxonomie.addVertex(nodeBasedAv); iaasTaxonomie.addVertex(publicCloud); iaasTaxonomie.addVertex(elasticityManager); iaasTaxonomie.addVertex(elasticLoadBalancer); iaasTaxonomie.addVertex(elasticQueue); iaasTaxonomie.addEdge(iaas, elasticInfrastructure); iaasTaxonomie.addEdge(elasticInfrastructure, envBasedAv); iaasTaxonomie.addEdge(elasticInfrastructure, nodeBasedAv); iaasTaxonomie.addEdge(elasticInfrastructure, elasticityManager); iaasTaxonomie.addEdge(elasticInfrastructure, elasticLoadBalancer); iaasTaxonomie.addEdge(elasticInfrastructure, elasticQueue); iaasTaxonomie.addEdge(envBasedAv, publicCloud); iaasTaxonomie.addEdge(iaas, nodeBasedAv); iaasTaxonomie.addEdge(iaas, envBasedAv);
if (keyword.equals(keywordBeanstalk)) { detectedPattern.add(patternPaaS); tempEdge = paasGraph.getEdge(paas.getElasticPlatform(), paas.getEnvBasedAv()); paasGraph.setEdgeWeight(tempEdge, 0.99); tempEdge = paasGraph.getEdge(paas.getElasticPlatform(), paas.getElasticLoadBalancer()); paasGraph.setEdgeWeight(tempEdge, 0.99); tempEdge = paasGraph.getEdge(paas.getElasticPlatform(), paas.getElasticityManager()); paasGraph.setEdgeWeight(tempEdge, 0.99); } else if (keyword.equals(keywordOpenstack) || keyword.equals(keywordEC2)) { tempEdge = iaasGraph.getEdge(iaas.getIaas(), iaas.getElasticInfrastructure()); iaasGraph.setEdgeWeight(tempEdge, 0.75); } else if (keyword.equals(keywordMySQL)) { tempEdge = paasGraph.getEdge(paas.getPaas(), paas.getRelationalDatabase()); paasGraph.setEdgeWeight(tempEdge, 0.99); tempEdge = paasGraph.getEdge(paas.getPaas(), paas.getKeyValueStorage()); paasGraph.setEdgeWeight(tempEdge, 0.0); } else if (keyword.equals(keywordJava) || keyword.equals(keywordPython) || keyword.equals(keywordTomcat) || keyword.equals(keywordApache)) { tempEdge = paasGraph.getEdge(paas.getPaas(), paas.getExecEnvironment()); paasGraph.setEdgeWeight(tempEdge, 0.75); } else if (keyword.equals(keywordMongoDB)) { tempEdge = paasGraph.getEdge(paas.getPaas(), paas.getKeyValueStorage()); paasGraph.setEdgeWeight(tempEdge, 0.99); tempEdge = paasGraph.getEdge(paas.getPaas(), paas.getRelationalDatabase()); paasGraph.setEdgeWeight(tempEdge, 0.0); impossiblePattern.add(patternPaaS); impossiblePattern.add(patternElasticPlatform); Set<DefaultWeightedEdge> edgeSet = iaasGraph.edgeSet();
public DefaultWeightedEdge addEdge(V sourceVertex, V targetVertex, int multiplicity) { if (multiplicity <= 0) { throw new IllegalArgumentException(NON_POSITIVE_MULTIPLICITY); } DefaultWeightedEdge edge = getEdge(sourceVertex, targetVertex); if (edge == null) { edge = super.addEdge(sourceVertex, targetVertex); setEdgeWeight(edge, multiplicity); } else { double oldWeight = getEdgeWeight(edge); setEdgeWeight(edge, oldWeight + multiplicity); } return edge; }
public List<Node> runInference() { List<DefaultWeightedEdge> path; if (negativeWeights) { path = BellmanFordShortestPath.findPathBetween(graph, source, target); } else { path = DijkstraShortestPath.findPathBetween(graph, source, target); } shortestPath = new ArrayList<Node>(); if (path == null) { System.out.println(graph); } DefaultWeightedEdge firstEdge = path.get(0); assert firstEdge != null; shortestPath.add(graph.getEdgeSource(firstEdge)); for (DefaultWeightedEdge e : path) { shortestPath.add(graph.getEdgeTarget(e)); } return shortestPath; }
final SimpleDirectedWeightedGraph< V, DefaultWeightedEdge > copy = new SimpleDirectedWeightedGraph< >( DefaultWeightedEdge.class ); final Set< Spot > spots = graph.vertexSet(); function.compute( spot, vertex ); map.put( spot, vertex ); copy.addVertex( vertex ); final DefaultWeightedEdge newEdge = copy.addEdge( map.get( graph.getEdgeSource( edge ) ), map.get( graph.getEdgeTarget( edge ) ) ); copy.setEdgeWeight( newEdge, graph.getEdgeWeight( edge ) );
public PaaSTaxonomy() { paasTaxonomie = new SimpleDirectedWeightedGraph<>(DefaultWeightedEdge.class); properties = new Properties(); try { paasTaxonomie.addVertex(paas); paasTaxonomie.addVertex(elasticPlatform); paasTaxonomie.addVertex(envBasedAv); paasTaxonomie.addVertex(nodeBasedAv); paasTaxonomie.addVertex(publicCloud); paasTaxonomie.addVertex(elasticityManager); paasTaxonomie.addVertex(elasticLoadBalancer); paasTaxonomie.addVertex(elasticQueue); paasTaxonomie.addVertex(relationalDatabase); paasTaxonomie.addVertex(execEnvironment); paasTaxonomie.addVertex(messagingMiddleware); paasTaxonomie.addVertex(keyValueStorage); paasTaxonomie.addEdge(paas, elasticPlatform); paasTaxonomie.addEdge(elasticPlatform, envBasedAv); paasTaxonomie.addEdge(elasticPlatform, nodeBasedAv); paasTaxonomie.addEdge(elasticPlatform, elasticityManager); paasTaxonomie.addEdge(elasticPlatform, elasticLoadBalancer); paasTaxonomie.addEdge(elasticPlatform, elasticQueue); paasTaxonomie.addEdge(elasticPlatform, relationalDatabase); paasTaxonomie.addEdge(elasticPlatform, keyValueStorage); paasTaxonomie.addEdge(elasticPlatform, messagingMiddleware); paasTaxonomie.addEdge(envBasedAv, publicCloud); paasTaxonomie.addEdge(paas, nodeBasedAv); paasTaxonomie.addEdge(paas, envBasedAv);
public DefaultWeightedEdge addEdge(V sourceVertex, V targetVertex, int multiplicity) { if (multiplicity <= 0) { throw new IllegalArgumentException(NON_POSITIVE_MULTIPLICITY); } DefaultWeightedEdge edge = getEdge(sourceVertex, targetVertex); if (edge == null) { edge = super.addEdge(sourceVertex, targetVertex); setEdgeWeight(edge, multiplicity); } else { double oldWeight = getEdgeWeight(edge); setEdgeWeight(edge, oldWeight + multiplicity); } return edge; }
public void updateEdgeWeight(Node s, Node t, double score) { DefaultWeightedEdge e = graph.getEdge(s, t); double sc = getNodeScore(t) + score; graph.setEdgeWeight(e, sc); if (sc < 0) negativeWeights = true; }
public List<Node> runInference() { List<DefaultWeightedEdge> path; if (negativeWeights) { path = BellmanFordShortestPath.findPathBetween(graph, source, target); } else { path = DijkstraShortestPath.findPathBetween(graph, source, target); } shortestPath = new ArrayList<Node>(); if (path == null) { System.out.println(graph); } DefaultWeightedEdge firstEdge = path.get(0); assert firstEdge != null; shortestPath.add(graph.getEdgeSource(firstEdge)); for (DefaultWeightedEdge e : path) { shortestPath.add(graph.getEdgeTarget(e)); } return shortestPath; }
public MaxFlowInference() { graph = new SimpleDirectedWeightedGraph<Node, DefaultWeightedEdge>( DefaultWeightedEdge.class); }
public void addEdge(Node s, Node t, double score) { DefaultWeightedEdge e = graph.addEdge(s, t); double sc = getNodeScore(t) + score; graph.setEdgeWeight(e, sc); if (sc < 0) negativeWeights = true; }
public DefaultWeightedEdge addEdge(final V sourceVertex, final V targetVertex, final int multiplicity) { if (multiplicity <= 0) throw new IllegalArgumentException(NON_POSITIVE_MULTIPLICITY); DefaultWeightedEdge edge = getEdge(sourceVertex, targetVertex); if (edge == null) { edge = super.addEdge(sourceVertex, targetVertex); setEdgeWeight(edge, multiplicity); } else { final double oldWeight = getEdgeWeight(edge); setEdgeWeight(edge, oldWeight + multiplicity); } return edge; }
public void updateEdgeWeight(Node s, Node t, double score) { DefaultWeightedEdge e = graph.getEdge(s, t); double sc = getNodeScore(t) + score; graph.setEdgeWeight(e, sc); }
public void addNode(Node node, double score) { graph.addVertex(node); if (score != 0) scores.put(node, score); }
@Override public Set<Node> runInference() throws Exception { EdmondsKarpMaximumFlow<Node, DefaultWeightedEdge> algo = new EdmondsKarpMaximumFlow<Node, DefaultWeightedEdge>(graph); algo.calculateMaximumFlow(source, sink); Map<DefaultWeightedEdge, Double> flow = algo.getMaximumFlow(); Set<Node> nodes = new HashSet<Node>(); for (Entry<DefaultWeightedEdge, Double> entry : flow.entrySet()) { if (entry.getValue() > 0) { DefaultWeightedEdge key = entry.getKey(); nodes.add(graph.getEdgeSource(key)); nodes.add(graph.getEdgeTarget(key)); } } return nodes; }