public Iterable<Vertex> getVertices(final String key, final Object value) { if (supportVertexIds && key.equals(ID)) { throw new IllegalArgumentException("index key " + ID + " is reserved by IdGraph"); } else { return new IdVertexIterable(baseGraph.getVertices(key, value), this); } }
public Iterable<Vertex> getVertices() { return new IdVertexIterable(baseGraph.getVertices(), this); }
/** * Return an iterable to all the vertices in the graph. * * @param mappingFunc the function to create a new dedicated vertex from another * @param <V> the type of the vertex after mapping * * @return an iterable reference to all vertices in the graph * * @see #getVertices() */ @Nonnull public <V extends Vertex> Iterable<V> getVertices(BiFunction<Vertex, G, V> mappingFunc) { return new IdElementIterable<>(baseGraph.getVertices(), v -> mappingFunc.apply(v, me())); }
public void run() { LOGGER.info("generating priority queue"); long startTime = System.currentTimeMillis(); for (Vertex v : graph.getPropertyGraph().getVertices()) { if (null != v.getProperty(Extendo.PRIORITY)) { Atom a = graph.getAtom(v); updatePriority(a); } } long endTime = System.currentTimeMillis(); LOGGER.info("\tfinished generating priority queue in " + (endTime - startTime) + "ms"); } }).start();
public Vertex getVertex(final Object id) { if (null == id) { throw new IllegalArgumentException("vertex identifier cannot be null"); } if (supportVertexIds) { final Iterable<Vertex> i = baseGraph.getVertices(ID, id); final Iterator<Vertex> iter = i.iterator(); if (!iter.hasNext()) { return null; } else { Vertex v = iter.next(); if (iter.hasNext()) { LOGGER.warning("multiple vertices exist with id '" + id + "'. Arbitarily choosing " + v); } return new IdVertex(v, this); } } else { Vertex base = baseGraph.getVertex(id); return null == base ? null : new IdVertex(base, this); } }
/** * Return an iterable to all the vertices in the graph that have a particular key/value property. * * @param key the key of vertex * @param value the value of the vertex * @param mappingFunc the function to create a new dedicated vertex from another * @param <V> the type of the vertex after mapping * * @return an iterable of vertices with provided key and value * * @see #getVertices(String, Object) */ @Nonnull public <V extends Vertex> Iterable<V> getVertices(String key, Object value, BiFunction<Vertex, G, V> mappingFunc) { checkIndexableKey(key, Vertex.class); return new IdElementIterable<>(baseGraph.getVertices(key, value), v -> mappingFunc.apply(v, me())); }
/** * Return the vertex referenced by the provided object identifier. * * @param id the identifier of the vertex * @param mappingFunc the function to create a new dedicated vertex from another * @param <V> the type of the vertex after mapping * * @return an {@link Optional} containing the vertex referenced by the provided identifier * * @see #getVertex(Object) */ @Nonnull public <V extends Vertex> Optional<V> getVertex(Object id, BiFunction<Vertex, G, V> mappingFunc) { checkNotNull(id, "id"); Optional<Vertex> vertex = supportVertexIds ? MoreIterables.onlyElement(baseGraph.getVertices(ID, id)) : Optional.ofNullable(baseGraph.getVertex(id)); return vertex.map(v -> mappingFunc.apply(v, me())); }
public void removeIsolatedAtoms(final Filter filter) { List<Vertex> toRemove = new LinkedList<Vertex>(); for (Vertex v : brain.getBrainGraph().getPropertyGraph().getVertices()) { if (null != v.getProperty("value") && !v.getEdges(Direction.IN).iterator().hasNext() && !v.getEdges(Direction.OUT).iterator().hasNext()) { Atom a = brain.getBrainGraph().getAtom(v); if (filter.isVisible(a)) { toRemove.add(v); } } } for (Vertex v : toRemove) { // note: we assume from the above that there are no dependent vertices (i.e. list nodes) to remove first brain.getBrainGraph().getPropertyGraph().removeVertex(v); } }
public Note findIsolatedAtoms(final Filter filter) { Note result = new Note(); for (Vertex v : brain.getBrainGraph().getPropertyGraph().getVertices()) { if (null != v.getProperty("value") && !v.getEdges(Direction.IN).iterator().hasNext() && !v.getEdges(Direction.OUT).iterator().hasNext()) { Atom a = brain.getBrainGraph().getAtom(v); if (filter.isVisible(a)) { Note n = viewInternal(a, 1, filter, FORWARD_ADJACENCY); result.addChild(n); } } } return result; }
public void migrate(final KeyIndexableGraph source, final KeyIndexableGraph target) { for (Vertex vs : source.getVertices()) { Vertex vt = target.addVertex(vs.getId()); for (Vertex vs : source.getVertices()) { Vertex vt = target.getVertex(vs.getId());
public Note findRoots(final Filter filter, final AdjacencyStyle style, final int depth) { Note result = new Note(); for (Vertex v : brain.getBrainGraph().getPropertyGraph().getVertices()) { Iterable<Edge> inEdges = v.getEdges(Direction.IN); if (!inEdges.iterator().hasNext()) { Atom a = brain.getBrainGraph().getAtom(v); if (filter.isVisible(a)) { Note n = viewInternal(a, depth, filter, style); result.addChild(n); } } } Collections.sort(result.getChildren(), new NoteComparator()); return result; }