@Override public boolean execute(int hashIndex, Set<WriteableImageOutput> itemSet) { for (final WriteableImageOutput item : itemSet) { if (!graph.containsVertex(item)) { graph.addVertex(item); } } final List<WriteableImageOutput> itemList = new ArrayList<WriteableImageOutput>(); itemList.addAll(itemSet); for (int i = 0; i < itemList.size(); i++) { final WriteableImageOutput itemA = itemList.get(i); for (int j = i + 1; j < itemList.size(); j++) { final WriteableImageOutput itemB = itemList.get(j); DefaultWeightedEdge edge = graph.getEdge(itemA, itemB); if (edge == null) { edge = graph.addEdge(itemA, itemB); graph.setEdgeWeight(edge, 1); } else { graph.setEdgeWeight(edge, graph.getEdgeWeight(edge) + 1); } } } return true; } });
weight = segmentCosts[i][j]; final DefaultWeightedEdge edge = graph.addEdge(end, start); graph.setEdgeWeight(edge, weight); weight = segmentCosts[i][j]; final DefaultWeightedEdge edge = graph.addEdge(end, middle); graph.setEdgeWeight(edge, weight); weight = segmentCosts[i][j]; final DefaultWeightedEdge edge = graph.addEdge(mother, start); graph.setEdgeWeight(edge, weight);
weight = segmentCosts[i][j]; final DefaultWeightedEdge edge = graph.addEdge(end, start); graph.setEdgeWeight(edge, weight); weight = segmentCosts[i][j]; final DefaultWeightedEdge edge = graph.addEdge(end, middle); graph.setEdgeWeight(edge, weight); weight = segmentCosts[i][j]; final DefaultWeightedEdge edge = graph.addEdge(mother, start); graph.setEdgeWeight(edge, weight);
/** * Returns the Equivalent Flow Tree as an actual tree (graph). Note that this tree is not * necessarily unique. The edge weights represent the flow values/cut weights. This method runs * in $O(n)$ time * * @return Equivalent Flow Tree */ public SimpleWeightedGraph<V, DefaultWeightedEdge> getEquivalentFlowTree() { if (p == null) // Lazy invocation of the algorithm this.calculateEquivalentFlowTree(); SimpleWeightedGraph<V, DefaultWeightedEdge> equivalentFlowTree = new SimpleWeightedGraph<>(DefaultWeightedEdge.class); Graphs.addAllVertices(equivalentFlowTree, vertexList); for (int i = 1; i < N; i++) { DefaultWeightedEdge e = equivalentFlowTree.addEdge(vertexList.get(i), vertexList.get(neighbors[i])); equivalentFlowTree.setEdgeWeight(e, flowMatrix[i][neighbors[i]]); } return equivalentFlowTree; }
graph.setEdgeWeight(edge, k.first);
graph.setEdgeWeight(edge, k.first);
synchronized (graph) { // To avoid concurrent access, sad but true final DefaultWeightedEdge edge = graph.addEdge(s0, s1); graph.setEdgeWeight(edge, weight);
synchronized (graph) { // To avoid concurrent access, sad but true final DefaultWeightedEdge edge = graph.addEdge(s0, s1); graph.setEdgeWeight(edge, weight);
graph.addVertex( target ); final DefaultWeightedEdge edge = graph.addEdge( source, target ); graph.setEdgeWeight( edge, cost );
graph.addVertex( target ); final DefaultWeightedEdge edge = graph.addEdge( source, target ); graph.setEdgeWeight( edge, cost );
continue; graph.setEdgeWeight( edge, weight );
synchronized (graph) { final DefaultWeightedEdge edge = graph.addEdge(source, targetNode.getValue()); graph.setEdgeWeight(edge, squareDist);
synchronized (graph) { final DefaultWeightedEdge edge = graph.addEdge(source, targetNode.getValue()); graph.setEdgeWeight(edge, squareDist);
public static void addConnectionToGraph(Connection connection, double connectionWeight, SimpleWeightedGraph<ConnectionPoint3D, DefaultWeightedEdge> graphToUpdate) { ConnectionPoint3D source = connection.getSourcePoint(); ConnectionPoint3D target = connection.getTargetPoint(); if (!source.epsilonEquals(target, 1.0e-3)) { graphToUpdate.addVertex(source); graphToUpdate.addVertex(target); DefaultWeightedEdge edge = new DefaultWeightedEdge(); graphToUpdate.addEdge(source, target, edge); graphToUpdate.setEdgeWeight(edge, connectionWeight); } }
protected WeightedGraph<Figure, DefaultWeightedEdge> extractNetwork(JCas jcas, Annotation range) { SimpleWeightedGraph<Figure, DefaultWeightedEdge> graph = new SimpleWeightedGraph<Figure, DefaultWeightedEdge>( DefaultWeightedEdge.class); for (Figure figure : JCasUtil.select(jcas, Figure.class)) { if (!graph.containsVertex(figure)) { graph.addVertex(figure); } } for (Scene scene : JCasUtil.select(jcas, Scene.class)) { List<Speaker> speakers = JCasUtil.selectCovered(Speaker.class, scene); for (Speaker s1 : speakers) { Figure gf1 = s1.getFigure(); if (gf1 != null) for (Speaker s2 : speakers) { Figure gf2 = s2.getFigure(); if (gf2 != null) if (graph.containsEdge(gf1, gf2)) { DefaultWeightedEdge edge = graph.getEdge(gf1, gf2); double w = graph.getEdgeWeight(edge); graph.setEdgeWeight(edge, w + 1.0); } else { if (gf1 != gf2) graph.addEdge(gf1, gf2); } } } ; } return graph; }
graph.setEdgeWeight( edge, cost );
graph.setEdgeWeight( edge, cost );
graph.setEdgeWeight( edge, edgeWeigth ); graph.setEdgeWeight( edge, edgeWeigth );
graph.setEdgeWeight( edge, edgeWeigth ); graph.setEdgeWeight( edge, edgeWeigth );
graph.setEdgeWeight( edge, 1 ); source = target;