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 addVertex(V v) { return delegate.addVertex(v); }
/** * {@inheritDoc} */ @Override public void generateGraph(Graph<V, E> target, Map<String, V> resultMap) { for (int i = 0; i < size; ++i) { target.addVertex(); } } }
public boolean addVertex( FlowElement flowElement ) { return graph.addVertex( flowElement ); }
private V addVertex(Graph<V, E> targetGraph, int i) { if (!vertexMap.containsKey(i)) { vertexMap.put(i, targetGraph.addVertex()); } return vertexMap.get(i); }
/** * Insert a new peak right before an existing one. * * @param toInsert the new peak to insert * @param before the existing peak before which insertion must be done */ public void insertPeak (StaffPeak toInsert, StaffPeak before) { int index = peaks.indexOf(before); if (index == -1) { throw new IllegalArgumentException("insertPeak() before a non-existing peak"); } peaks.add(index, toInsert); peakGraph.addVertex(toInsert); }
/** * Adds {@code vertex} to the graph being built. * * @param vertex the vertex to add * * @return this builder object * * @see Graph#addVertex(Object) */ public B addVertex(V vertex) { this.graph.addVertex(vertex); return this.self(); }
/** * {@inheritDoc} */ @Override public V addVertex() { /* * Use our own vertex supplier, if provided. */ if (vertexSupplier != null) { V v = vertexSupplier.get(); return this.addVertex(v) ? v : null; } return delegate.addVertex(); }
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); } }
@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; }
public void processPrimitivePath(Path path) { D edgeLabel = primitivePathMapper.apply(path); V s = vertexFactory.get(); graph.addVertex(s); PartialNfa<V, D> partialNfa = PartialNfa.create(s, Collections.singletonList(new HalfEdge<V, D>(s, edgeLabel))); stack.push(partialNfa); }
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); } }
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."); } } }
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)); }
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); } }