com.tinkerpop.blueprints.Graph.getVertices()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中com.tinkerpop.blueprints.Graph.getVertices()方法的一些代码示例,展示了Graph.getVertices()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getVertices()方法的具体详情如下:
包路径:com.tinkerpop.blueprints.Graph
类名称:Graph
方法名:getVertices

Graph.getVertices介绍

[英]Return an iterable to all the vertices in the graph. If this is not possible for the implementation, then an UnsupportedOperationException can be thrown.
[中]将iterable返回到图形中的所有顶点。如果这对于实现是不可能的,那么可以抛出UnsupportedOperationException。

代码示例

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-graph-jung

public int getVertexCount() {
  final Iterable<Vertex> itty = this.graph.getVertices();
  if (itty instanceof Collection) {
    return ((Collection) itty).size();
  } else {
    int count = 0;
    for (final Vertex vertex : itty) {
      count++;
    }
    return count;
  }
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-graph-jung

public Collection<Vertex> getVertices() {
  final Iterable<Vertex> itty = this.graph.getVertices();
  if (itty instanceof Collection) {
    return (Collection<Vertex>) itty;
  } else {
    final List<Vertex> vertices = new ArrayList<Vertex>();
    for (final Vertex v : itty) {
      vertices.add(v);
    }
    return vertices;
  }
}

代码示例来源:origin: fr.lirmm.graphik/graal-store-blueprints

@Override
public Set<Term> getTerms() {
  Set<Term> terms = new TreeSet<Term>();
  for (Vertex v : this.graph.getVertices("class", "term")) {
    terms.add(vertexToTerm(v));
  }
  return terms;
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

private void populateLists(final List<Vertex> vertices, final List<Edge> edges) {
  for (Vertex v : graph.getVertices()) {
    vertices.add(v);
  }
  for (Edge e : graph.getEdges()) {
    edges.add(e);
  }
}

代码示例来源:origin: com.thinkaurelius.titan/titan-test-jre6

/**
 * Generates a synthetic network connecting all vertices in the provided graph with the expected number
 * of edges.
 *
 * @param graph
 * @param expectedNumEdges
 * @return The number of generated edges. Not that this number may not be equal to the expected number of edges
 */
public int generate(Graph graph, int expectedNumEdges) {
  return generate(graph,graph.getVertices(),expectedNumEdges);
}

代码示例来源:origin: org.hawkular.titan/titan-test

/**
 * Generates a synthetic network connecting all vertices in the provided graph with the expected number
 * of edges.
 *
 * @param graph
 * @param expectedNumEdges
 * @return The number of generated edges. Not that this number may not be equal to the expected number of edges
 */
public int generate(Graph graph, int expectedNumEdges) {
  return generate(graph,graph.getVertices(),expectedNumEdges);
}

代码示例来源:origin: iTransformers/netTransformer

private void mergeVertexes(Graph graph1, Graph graph2) {
  for (Vertex vertex2 : graph2.getVertices()) {
    mergeVertex(graph1, vertex2);
  }
}

代码示例来源:origin: SciGraph/SciGraph

public void project(Collection<String> projection) {
 if (projection.contains("*")) {
  return;
 }
 for (Vertex vertex : graph.getVertices()) {
  for (String key : vertex.getPropertyKeys()) {
   if (!projection.contains(key) && !PROTECTED_PROPERTY_KEYS.contains(key)) {
    vertex.removeProperty(key);
   }
  }
 }
}

代码示例来源:origin: fr.lirmm.graphik/graal-store-blueprints

@Override
public CloseableIterator<Atom> iterator() {
  GIterator<Vertex> it = new IteratorAdapter<Vertex>(this.graph.getVertices("class", "atom")
      .iterator());
  return new AtomIterator(it);
}

代码示例来源:origin: org.jboss.windup/windup-grapher

private void writeGraphNodes(OutputStream os) throws IOException {
  //iterate the nodes.
  for(Vertex vertex : graph.getVertices()) {
    String id = ""+vertex.getId().hashCode();
    String label = vertex.getProperty(vertexLabelProperty);
    
    if(StringUtils.isBlank(label)) {
      label = vertex.toString();
    }
    writeGraphNode(id, label, os);
  }
  
}

代码示例来源:origin: org.jboss.windup.legacy.application/grapher

private void writeGraphNodes(OutputStream os) throws IOException {
  //iterate the nodes.
  for(Vertex vertex : graph.getVertices()) {
    String id = ""+vertex.getId().hashCode();
    String label = vertex.getProperty(vertexLabelProperty);
    
    if(StringUtils.isBlank(label)) {
      label = vertex.toString();
    }
    writeGraphNode(id, label, os);
  }
  
}

代码示例来源:origin: SciGraph/SciGraph

void addCuries(Graph graph) {
 for (Vertex vertex: graph.getVertices()) {
  String iri = (String)vertex.getProperty(CommonProperties.IRI);
  Optional<String> curie = curieUtil.getCurie(iri);
  if (curie.isPresent()) {
   vertex.setProperty(CommonProperties.CURIE, curie.get());
  }
 }
}

代码示例来源:origin: fr.lirmm.graphik/graal-store-blueprints

private void init() {
  try {
    this.graph.getVertices("class", "");
  } catch (IllegalArgumentException e) {
    Vertex v = this.graph.addVertex(null);
    v.setProperty("class", "");
  }
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void edges_queryIsEntailed() {
 Graph graph = graphApi.getEdges(OwlRelationships.RDFS_SUBCLASS_OF, true, 0L, 1L);
 assertThat(size(graph.getVertices()), is(2));
 assertThat(size(graph.getEdges()), is(1));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void getReachableNodes_filtersCorrectly() {
 Graph graph = graphApi.getReachableNodes(c, Lists.newArrayList("*"), Sets.newHashSet("alabel"));
 assertThat(size(graph.getVertices()), is(1));
 assertThat(size(graph.getEdges()), is(0));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void testPredicate() {
 Predicate<Node> testPredicate = new Predicate<Node>() {
  @Override
  public boolean apply(Node node) {
   return (node != c);
  }};
  Graph graph = graphApi.getNeighbors(newHashSet(b), 1, Collections.<DirectedRelationshipType>emptySet(), Optional.of(testPredicate));
  assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(4));
  assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(3));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void getReachableNodes_nothingReturnedForFakeLabel() {
 Graph graph = graphApi.getReachableNodes(c,
   Lists.newArrayList(OwlRelationships.OWL_EQUIVALENT_CLASS.name(),
     OwlRelationships.RDFS_SUBCLASS_OF.name()),
   Sets.newHashSet("fakeLabel"));
 assertThat(size(graph.getVertices()), is(0));
 assertThat(size(graph.getEdges()), is(0));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void evidenceIsAdded() {
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(5));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(1));
 aspect.invoke(graph);
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(6));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(3));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void testMultiTypedNeighborhood() {
 Graph graph = graphApi.getNeighbors(newHashSet(b), 1, 
   newHashSet(new DirectedRelationshipType(OwlRelationships.RDFS_SUBCLASS_OF, Direction.INCOMING),
     new DirectedRelationshipType(fizz, Direction.INCOMING)), absent);
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(3));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(2));
}

代码示例来源:origin: SciGraph/SciGraph

public static void dumpGraph(com.tinkerpop.blueprints.Graph graphDb) {
 for (Vertex node: graphDb.getVertices()) {
  dumpNode(node);
 }
 for (Edge relationship: graphDb.getEdges()) {
  dumpRelationship(relationship);
 }
}

相关文章