private void addType(ErrorTypeDefinition<?> errorType, Graph<ErrorTypeDefinition, Pair<ErrorTypeDefinition, ErrorTypeDefinition>> graph) { graph.addVertex(errorType); String type = errorType.getType(); if (!ANY.name().equals(type) && !CRITICAL.name().equals(type)) { ErrorTypeDefinition parentErrorType = errorType.getParent().orElse((ANY)); graph.addVertex(parentErrorType); graph.addEdge(errorType, parentErrorType); } }
/** * {@inheritDoc} */ @Override public boolean addEdge(V sourceVertex, V targetVertex, E e) { return delegate.addEdge(sourceVertex, targetVertex, e); }
@Override protected void addUses(final ATermAppl c, final ATermAppl usedByC) { if (c.equals(TOP)) addEquivalent(TOP, usedByC); else if (!c.equals(usedByC)) _graph.addEdge(c, usedByC); }
@Override protected void addUses(final ATermAppl c, final ATermAppl usedByC) { if (c.equals(TOP)) addEquivalent(TOP, usedByC); else if (!c.equals(usedByC)) _graph.addEdge(c, usedByC); }
/** * {@inheritDoc} */ @Override public E addEdge(V sourceVertex, V targetVertex) { /* * Use our own edge supplier, if provided. */ if (edgeSupplier != null) { E e = edgeSupplier.get(); return this.addEdge(sourceVertex, targetVertex, e) ? e : null; } return delegate.addEdge(sourceVertex, targetVertex); }
private void generateNonSimpleRegularGraph(Graph<V, E> target) { List<V> vertices = new ArrayList<>(n * d); for (int i = 0; i < n; i++) { V vertex = target.addVertex(); for (int j = 0; j < d; j++) { vertices.add(vertex); } } Collections.shuffle(vertices, rng); for (int i = 0; i < (n * d) / 2; i++) { V u = vertices.get(2 * i); V v = vertices.get(2 * i + 1); target.addEdge(u, v); } }
private <S, D> void addEdge( final Class<S> source, final Class<D> target, final Function<? super S, ? extends D> implicit) { edgeFactory.addImplicitConversion(source, target, implicit); implicits.removeEdge(source, target); Objects.requireNonNull(implicits.addEdge(source, target)); }
/** * {@inheritDoc} */ @Override public void generateGraph(Graph<V, E> target, Map<String, V> resultMap) { if (size < 1) { return; } Map<String, V> privateMap = new HashMap<>(); new LinearGraphGenerator<V, E>(size).generateGraph(target, privateMap); V startVertex = privateMap.get(LinearGraphGenerator.START_VERTEX); V endVertex = privateMap.get(LinearGraphGenerator.END_VERTEX); target.addEdge(endVertex, startVertex); } }
private void addEdge(Graph<V, E> targetGraph, int i, int j) { V u = addVertex(targetGraph, i); V v = addVertex(targetGraph, j); targetGraph.addEdge(u, v); }
public boolean addEdge( FlowElement sourceVertex, FlowElement targetVertex, Scope scope ) { // prevent multiple edges from head or to tail if( !allowMultipleExtentEdges() && ( sourceVertex == Extent.head || targetVertex == Extent.tail ) && graph.containsEdge( sourceVertex, targetVertex ) ) return true; return graph.addEdge( sourceVertex, targetVertex, scope ); }
public Scope addEdge( FlowElement sourceVertex, FlowElement targetVertex ) { // prevent multiple edges from head or to tail if( !allowMultipleExtentEdges() && ( sourceVertex == Extent.head || targetVertex == Extent.tail ) && graph.containsEdge( sourceVertex, targetVertex ) ) return graph.getEdge( sourceVertex, targetVertex ); return graph.addEdge( sourceVertex, targetVertex ); }
private void addType(ErrorTypeDefinition<?> errorType, Graph<ErrorTypeDefinition, Pair<ErrorTypeDefinition, ErrorTypeDefinition>> graph) { graph.addVertex(errorType); String type = errorType.getType(); if (!ANY.name().equals(type) && !CRITICAL.name().equals(type)) { ErrorTypeDefinition parentErrorType = errorType.getParent().orElse((ANY)); graph.addVertex(parentErrorType); graph.addEdge(errorType, parentErrorType); } }
public static void addEdge(org.jgrapht.Graph<Node, LabeledEdge<Node, Node>> graph, Node edgeLabel, Node source, Node target) { graph.addVertex(source); graph.addVertex(target); graph.addEdge(source, target, new LabeledEdgeImpl<>(source, target, edgeLabel)); }
public static void addEdge(org.jgrapht.Graph<Node, LabeledEdge<Node, Node>> graph, Node edgeLabel, Node source, Node target) { graph.addVertex(source); graph.addVertex(target); graph.addEdge(source, target, new LabeledEdgeImpl<>(source, target, edgeLabel)); }
static public <V, E> void copyTo(Graph<V, E> source, Graph<V, E> target) { for (V vertex : source.vertexSet()) { target.addVertex(vertex); } for (E edge : source.edgeSet()) { final boolean added = target.addEdge(source.getEdgeSource(edge), source.getEdgeTarget(edge), edge); if (!added) { throw new IllegalArgumentException("Target graph does not support addition of (some) source edges."); } } }
@Override public boolean addHeadVertex( FlowElement flowElement ) { if( !graph.containsVertex( Extent.head ) ) graph.addVertex( Extent.head ); if( flowElement == Extent.head ) return false; boolean result = true; if( !graph.containsVertex( flowElement ) ) result = graph.addVertex( flowElement ); return result && graph.addEdge( Extent.head, flowElement ) != null; }
@Override public boolean addTailVertex( FlowElement flowElement ) { if( !graph.containsVertex( Extent.tail ) ) graph.addVertex( Extent.tail ); if( flowElement == Extent.tail ) return false; boolean result = true; if( !graph.containsVertex( flowElement ) ) result = graph.addVertex( flowElement ); return result && graph.addEdge( flowElement, Extent.tail ) != null; }
private Pair<V, Graph<V, E>> createSingleRootGraph(Graph<V, E> forest, Set<V> roots) { Graph<V, E> freshForest = GraphTypeBuilder.forGraph(forest).weighted(false).buildGraph(); roots.forEach(freshForest::addVertex); V freshVertex = freshForest.addVertex(); for (V root : roots) freshForest.addEdge(freshVertex, root); return Pair.of(freshVertex, new AsGraphUnion<>(freshForest, forest)); }
@Override protected void transformGraph(List<E> previousPath) { V source, target; E reversedEdge; // replace previous path edges with reversed edges with negative weight for (E originalEdge : previousPath) { source = workingGraph.getEdgeSource(originalEdge); target = workingGraph.getEdgeTarget(originalEdge); double originalEdgeWeight = workingGraph.getEdgeWeight(originalEdge); workingGraph.removeEdge(originalEdge); workingGraph.addEdge(target, source); reversedEdge = workingGraph.getEdge(target, source); workingGraph.setEdgeWeight(reversedEdge, -originalEdgeWeight); } }
private void buildGraph(Graph<Vertex, Edge> graph, QueryTree<N> tree){ PrefixCCMap prefixes = PrefixCCMap.getInstance(); List<QueryTree<N>> children = tree.getChildren(); Vertex parent = new Vertex(tree.getId(), prefixed(prefixes, tree.getUserObject().toString())); graph.addVertex(parent); for (QueryTree<N> child : children) { Vertex childVertex = new Vertex(child.getId(), prefixed(prefixes, child.getUserObject().toString())); graph.addVertex(childVertex); Edge edge = new Edge(Long.parseLong(parent.getId() + "0" + childVertex.getId()), prefixed(prefixes, tree.getEdge(child).toString())); graph.addEdge(parent, childVertex, edge); buildGraph(graph, child); } }