org.apache.tinkerpop.gremlin.structure.Vertex.vertices()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(89)

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

Vertex.vertices介绍

[英]Gets an Iterator of adjacent vertices.
[中]获取相邻顶点的迭代器。

代码示例

代码示例来源:origin: apache/tinkerpop

private boolean sameOutVertices(final Vertex v, final List<Vertex> outVertices) {
    return outVertices.stream()
        .allMatch(outVertex -> IteratorUtils.filter(v.vertices(Direction.OUT), hv -> hv.value("oid").equals(outVertex.value("oid"))).hasNext());
  }
}

代码示例来源:origin: apache/tinkerpop

private boolean sameInVertices(final Vertex v, final List<Vertex> inVertices) {
  return inVertices.stream()
      .allMatch(inVertex -> IteratorUtils.filter(v.vertices(Direction.IN), hv -> hv.value("oid").equals(inVertex.value("oid"))).hasNext());
}

代码示例来源:origin: apache/tinkerpop

@Override
protected Iterator<E> flatMap(final Traverser.Admin<Vertex> traverser) {
  return Vertex.class.isAssignableFrom(this.returnClass) ?
      (Iterator<E>) traverser.get().vertices(this.direction, this.edgeLabels) :
      (Iterator<E>) traverser.get().edges(this.direction, this.edgeLabels);
}

代码示例来源:origin: apache/tinkerpop

@Override
public void execute(Vertex vertex, Messenger messenger, Memory memory) {
  vertex.vertices(Direction.OUT).forEachRemaining(Vertex::id);
  vertex.vertices(Direction.IN).forEachRemaining(Vertex::id);
  vertex.vertices(Direction.BOTH).forEachRemaining(Vertex::id);
  if (vertex.vertices(Direction.OUT).hasNext()) {
    try {
      vertex.vertices(Direction.OUT).forEachRemaining(Vertex::label);
      fail("Adjacent vertex labels should not be accessible in VertexProgram.execute()");
    } catch (UnsupportedOperationException e) {
  if (vertex.vertices(Direction.IN).hasNext()) {
    try {
      vertex.vertices(Direction.IN).forEachRemaining(Vertex::label);
      fail("Adjacent vertex labels should not be accessible in VertexProgram.execute()");
    } catch (UnsupportedOperationException e) {
  if (vertex.vertices(Direction.BOTH).hasNext()) {
    try {
      vertex.vertices(Direction.BOTH).forEachRemaining(Vertex::label);
      fail("Adjacent vertex labels should not be accessible in VertexProgram.execute()");
    } catch (UnsupportedOperationException e) {
  if (vertex.vertices(Direction.OUT).hasNext()) {
    try {
      vertex.vertices(Direction.OUT).forEachRemaining(v -> v.property("name"));
      fail("Adjacent vertex properties should not be accessible in VertexProgram.execute()");
    } catch (UnsupportedOperationException e) {
  if (vertex.vertices(Direction.IN).hasNext()) {

代码示例来源:origin: apache/tinkerpop

@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
  return IteratorUtils.map(this.getBaseVertex().vertices(direction, edgeLabels), vertex -> HadoopVertex.this.graph.vertices(vertex.id()).next());
}

代码示例来源:origin: apache/tinkerpop

@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
  if (state.equals(State.MAP_REDUCE))
    throw GraphComputer.Exceptions.incidentAndAdjacentElementsCanNotBeAccessedInMapReduce();
  return IteratorUtils.map(this.getBaseVertex().vertices(direction, edgeLabels), v -> v.equals(starVertex) ? starVertex : new ComputerAdjacentVertex(v));
}

代码示例来源:origin: apache/tinkerpop

/**
 * Asserts that two graphs are the "same" in way of structure.  It assumes that the graphs both have vertices
 * with an "oid" property that is an Integer value.  It iterates each vertex in graph 1, using the "oid" to
 * lookup vertices in graph 2.  For each one found it checks both IN and OUT vertices to ensure that they
 * attach to the same IN/OUT vertices given their "oid" properties.
 */
protected boolean same(final Graph g1, final Graph g2) {
  return IteratorUtils.stream(g1.vertices())
      .map(v -> Triplet.<Integer, List<Vertex>, List<Vertex>>with(v.value("oid"), IteratorUtils.list(v.vertices(Direction.IN)), IteratorUtils.list(v.vertices(Direction.OUT))))
      .allMatch(p -> {
        final Vertex v = IteratorUtils.filter(g2.vertices(), vx -> vx.value("oid").equals(p.getValue0())).next();
        return sameInVertices(v, p.getValue1()) && sameOutVertices(v, p.getValue2());
      });
}

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

@Test
public void testQueryBothVerticesOfVertex() {
  HugeGraph graph = graph();
  init18Edges();
  Vertex jeff = vertex("person", "name", "Jeff");
  List<Vertex> vertices = graph.traversal().V(jeff.id())
              .both("friend").toList();
  Assert.assertEquals(2, vertices.size());
  vertices = ImmutableList.copyOf(
        jeff.vertices(Direction.BOTH, "friend"));
  Assert.assertEquals(2, vertices.size());
}

代码示例来源:origin: apache/tinkerpop

for (Edge a : IteratorUtils.list(start.edges(Direction.OUT))) {
  assertEquals(graphProvider.convertLabel("test1"), a.label());
  assertEquals(branchSize, IteratorUtils.count(a.inVertex().vertices(Direction.OUT)));
  assertEquals(1, IteratorUtils.count(a.inVertex().vertices(Direction.IN)));
  for (Edge b : IteratorUtils.list(a.inVertex().edges(Direction.OUT))) {
    assertEquals(graphProvider.convertLabel("test2"), b.label());
    assertEquals(branchSize, IteratorUtils.count(b.inVertex().vertices(Direction.OUT)));
    assertEquals(1, IteratorUtils.count(b.inVertex().vertices(Direction.IN)));
    for (Edge c : IteratorUtils.list(b.inVertex().edges(Direction.OUT))) {
      assertEquals(graphProvider.convertLabel("test3"), c.label());
      assertEquals(0, IteratorUtils.count(c.inVertex().vertices(Direction.OUT)));
      assertEquals(1, IteratorUtils.count(c.inVertex().vertices(Direction.IN)));

代码示例来源:origin: org.janusgraph/janusgraph-hadoop

private static Boolean isLoopAdded(Vertex vertex, String label) {
  Iterator<Vertex> adjacentVertices = vertex.vertices(Direction.BOTH, label);
  while (adjacentVertices.hasNext()) {
    Vertex adjacentVertex = adjacentVertices.next();
    if(adjacentVertex.equals(vertex)){
      return true;
    }
  }
  return false;
}

代码示例来源:origin: apache/tinkerpop

assertEquals("thing", v1.label());
Edge e1 = v1.addEdge("self", v1, "name", "pipes");
assertEquals(2l, IteratorUtils.count(v1.vertices(Direction.BOTH, "self", "nothing")));
assertEquals(1l, IteratorUtils.count(v1.vertices(Direction.OUT)));
assertEquals(1l, IteratorUtils.count(v1.vertices(Direction.IN, "self")));
edgeIterator = v1.edges(Direction.BOTH);
TestHelper.validateEdgeEquality(e1, edgeIterator.next());

代码示例来源:origin: HuygensING/timbuctoo

@Override
 public List<String> getValues(Vertex vertex, String propertyName) {
  List<String> result = new ArrayList<>();
  vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> {
   List<String> values = super.getValues(targetVertex, propertyName);
   values.forEach(result::add);
  });
  return result;
 }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-test

private boolean sameOutVertices(final Vertex v, final List<Vertex> outVertices) {
    return outVertices.stream()
        .allMatch(outVertex -> IteratorUtils.filter(v.vertices(Direction.OUT), hv -> hv.value("oid").equals(outVertex.value("oid"))).hasNext());
  }
}

代码示例来源:origin: HuygensING/timbuctoo

public Optional<String> getPropertyType(String collectionPropertyName) {
 Iterator<Vertex> vertices = vertex.vertices(Direction.OUT, HAS_PROPERTY_RELATION_NAME);
 final Optional<Vertex> knownProperty = getKnownProperty(collectionPropertyName, vertices);
 if (knownProperty.isPresent() && knownProperty.get().property(LocalProperty.PROPERTY_TYPE_NAME).isPresent()) {
  return Optional.of(knownProperty.get().<String>property(LocalProperty.PROPERTY_TYPE_NAME).value());
 }
 return Optional.empty();
}

代码示例来源:origin: HuygensING/timbuctoo

@Override
 public List<String> getValues(Vertex vertex, String propertyName) {
  List<String> result = new ArrayList<>();
  vertex.vertices(Direction.BOTH, relations).forEachRemaining(targetVertex -> {
   if (targetVertex.property(propertyName).isPresent()) {
    result.add((String) targetVertex.property(propertyName).value());
   }
  });
  return result;
 }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
protected Iterator<E> flatMap(final Traverser.Admin<Vertex> traverser) {
  return Vertex.class.isAssignableFrom(this.returnClass) ?
      (Iterator<E>) traverser.get().vertices(this.direction, this.edgeLabels) :
      (Iterator<E>) traverser.get().edges(this.direction, this.edgeLabels);
}

代码示例来源:origin: org.hawkular.inventory/hawkular-inventory-impl-tinkerpop

private StructuredData loadStructuredData(Vertex owner, Relationships.WellKnown owningEdge) {
  Iterator<Vertex> it = owner.vertices(Direction.OUT, owningEdge.name());
  if (!it.hasNext()) {
    closeIfNeeded(it);
    return null;
  }
  return loadStructuredData(closeAfter(it, it::next), true);
}

代码示例来源:origin: HuygensING/timbuctoo

private void handleRelationChange(Collection collection, Edge edge) {
 if ("isCreatedBy".equals(edge.label()) && "wwrelation".equals(collection.getEntityTypeName())) {
  Vertex document = edge.outVertex();
  Vertex oldDocument = document.vertices(Direction.IN, "VERSION_OF").next();
  Collection wwdocuments = collection.getVre().getCollectionForTypeName("wwdocument");
  handleChange(wwdocuments, document, oldDocument);
 }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
  if (state.equals(State.MAP_REDUCE))
    throw GraphComputer.Exceptions.incidentAndAdjacentElementsCanNotBeAccessedInMapReduce();
  return IteratorUtils.map(this.getBaseVertex().vertices(direction, edgeLabels), v -> v.equals(starVertex) ? starVertex : new ComputerAdjacentVertex(v));
}

代码示例来源:origin: rayokota/hgraphdb

private Iterator<Vertex> lookupVertices(final Traverser.Admin<Vertex> traverser, final List<HasContainer> hasContainers) {
  // linear scan
  return CloseableIteratorUtils.filter(traverser.get().vertices(getDirection(), getEdgeLabels()),
      vertex -> HasContainer.testAll(vertex, hasContainers));
}

相关文章