Java Code Examples for org.apache.tinkerpop.gremlin.structure.Edge#vertices()

The following examples show how to use org.apache.tinkerpop.gremlin.structure.Edge#vertices() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FactEdgeTest.java    From act-platform with ISC License 6 votes vote down vote up
@Test
public void testReturnOutThenInOnVertexIterator() {
  UUID factID = mockFact(null);
  UUID inVertexObjectID = mockObject();
  UUID outVertexObjectID = mockObject();
  Edge edge = new FactEdge(getActGraph(), factID, inVertexObjectID, outVertexObjectID);

  assertEquals(outVertexObjectID, edge.outVertex().id());
  assertEquals(inVertexObjectID, edge.inVertex().id());

  Iterator<Vertex> vertices = edge.vertices(Direction.BOTH);
  assertTrue(vertices.hasNext());
  assertEquals(outVertexObjectID, vertices.next().id());
  assertTrue(vertices.hasNext());
  assertEquals(inVertexObjectID, vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 2
Source File: FactEdgeTest.java    From act-platform with ISC License 6 votes vote down vote up
@Test
public void testVerticesWithDirectionIn() {
  ObjectVertex destination = createVertex();
  ObjectVertex source = createVertex();

  Edge edge = FactEdge.builder()
          .setGraph(actGraph)
          .setFactRecord(new FactRecord())
          .setFactType(FactTypeStruct.builder().build())
          .setInVertex(destination)
          .setOutVertex(source)
          .build();

  Iterator<Vertex> vertices = edge.vertices(Direction.IN);
  assertSame(destination.id(), vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 3
Source File: FactEdgeTest.java    From act-platform with ISC License 6 votes vote down vote up
@Test
public void testVerticesWithDirectionOut() {
  ObjectVertex destination = createVertex();
  ObjectVertex source = createVertex();

  Edge edge = FactEdge.builder()
          .setGraph(actGraph)
          .setFactRecord(new FactRecord())
          .setFactType(FactTypeStruct.builder().build())
          .setInVertex(destination)
          .setOutVertex(source)
          .build();

  Iterator<Vertex> vertices = edge.vertices(Direction.OUT);
  assertSame(source.id(), vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 4
Source File: FactEdgeTest.java    From act-platform with ISC License 6 votes vote down vote up
@Test
public void testVerticesWithDirectionBoth() {
  ObjectVertex destination = createVertex();
  ObjectVertex source = createVertex();

  Edge edge = FactEdge.builder()
          .setGraph(actGraph)
          .setFactRecord(new FactRecord())
          .setFactType(FactTypeStruct.builder().build())
          .setInVertex(destination)
          .setOutVertex(source)
          .build();

  Iterator<Vertex> vertices = edge.vertices(Direction.BOTH);
  assertSame(source.id(), vertices.next().id());
  assertSame(destination.id(), vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 5
Source File: FactEdgeTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testVerticesWithDirectionIn() {
  UUID factID = mockFact(null);
  UUID inVertexObjectID = mockObject();
  UUID outVertexObjectID = mockObject();
  Edge edge = new FactEdge(getActGraph(), factID, inVertexObjectID, outVertexObjectID);

  Iterator<Vertex> vertices = edge.vertices(Direction.IN);
  assertSame(inVertexObjectID, vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 6
Source File: FactEdgeTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testVerticesWithDirectionOut() {
  UUID factID = mockFact(null);
  UUID inVertexObjectID = mockObject();
  UUID outVertexObjectID = mockObject();
  Edge edge = new FactEdge(getActGraph(), factID, inVertexObjectID, outVertexObjectID);

  Iterator<Vertex> vertices = edge.vertices(Direction.OUT);
  assertSame(outVertexObjectID, vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 7
Source File: FactEdgeTest.java    From act-platform with ISC License 5 votes vote down vote up
@Test
public void testVerticesWithDirectionBoth() {
  UUID factID = mockFact(null);
  UUID inVertexObjectID = mockObject();
  UUID outVertexObjectID = mockObject();
  Edge edge = new FactEdge(getActGraph(), factID, inVertexObjectID, outVertexObjectID);

  Iterator<Vertex> vertices = edge.vertices(Direction.BOTH);
  assertSame(outVertexObjectID, vertices.next().id());
  assertSame(inVertexObjectID, vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
Example 8
Source File: SubgraphStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private void addEdgeToSubgraph(final Edge edge) {
    final Iterator<Edge> edgeIterator = subgraph.edges(edge.id());

    try {
        if (edgeIterator.hasNext()) return;
    } finally {
        CloseableIterator.closeIterator(edgeIterator);
    }

    final Iterator<Vertex> vertexIterator = edge.vertices(Direction.BOTH);
    final Vertex subGraphOutVertex = getOrCreate(vertexIterator.next());
    final Vertex subGraphInVertex = getOrCreate(vertexIterator.next());
    final Edge subGraphEdge = subGraphOutVertex.addEdge(edge.label(), subGraphInVertex, T.id, edge.id());
    edge.properties().forEachRemaining(property -> subGraphEdge.property(property.key(), property.value()));
}