ToVertices

See javadoc - uk.gov.gchq.gaffer.operation.impl.output.ToVertices

Available since Gaffer version 1.0.0

In these examples we use a ToSet operation after the ToVertices operation to deduplicate the results.

Required fields

No required fields

Examples

Extract entity vertices

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final OperationChain<Set<?>> opChain = new Builder()
        .first(new GetElements.Builder()
                .input(new EntitySeed(1), new EntitySeed(2))
                .view(new View.Builder()
                        .entity("entity")
                        .build())
                .build())
        .then(new ToVertices.Builder()
                .edgeVertices(ToVertices.EdgeVertices.NONE)
                .build())
        .then(new ToSet<>())
        .build();
{
  "class" : "OperationChain",
  "operations" : [ {
    "class" : "GetElements",
    "input" : [ {
      "class" : "EntitySeed",
      "vertex" : 1
    }, {
      "class" : "EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "entities" : {
        "entity" : { }
      }
    }
  }, {
    "class" : "ToVertices",
    "edgeVertices" : "NONE"
  }, {
    "class" : "ToSet"
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements",
    "input" : [ {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 1
    }, {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "entities" : {
        "entity" : { }
      }
    }
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices",
    "edgeVertices" : "NONE"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet"
  } ]
}
g.OperationChain( 
  operations=[ 
    g.GetElements( 
      input=[ 
        g.EntitySeed( 
          vertex=1 
        ), 
        g.EntitySeed( 
          vertex=2 
        ) 
      ], 
      view=g.View( 
        entities=[ 
          g.ElementDefinition( 
            group="entity" 
          ) 
        ] 
      ) 
    ), 
    g.ToVertices( 
      edge_vertices="NONE" 
    ), 
    g.ToSet() 
  ] 
)

Result:

Java
JSON
1
2
[ 1, 2 ]


Extract destination vertex

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final OperationChain<Set<?>> opChain = new Builder()
        .first(new GetElements.Builder()
                .input(new EntitySeed(1), new EntitySeed(2))
                .inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING)
                .view(new View.Builder()
                        .edge("edge")
                        .build())
                .build())
        .then(new ToVertices.Builder()
                .edgeVertices(ToVertices.EdgeVertices.DESTINATION)
                .build())
        .then(new ToSet<>())
        .build();
{
  "class" : "OperationChain",
  "operations" : [ {
    "class" : "GetElements",
    "input" : [ {
      "class" : "EntitySeed",
      "vertex" : 1
    }, {
      "class" : "EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "ToVertices",
    "edgeVertices" : "DESTINATION"
  }, {
    "class" : "ToSet"
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements",
    "input" : [ {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 1
    }, {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices",
    "edgeVertices" : "DESTINATION"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet"
  } ]
}
g.OperationChain( 
  operations=[ 
    g.GetElements( 
      include_incoming_out_going="OUTGOING", 
      input=[ 
        g.EntitySeed( 
          vertex=1 
        ), 
        g.EntitySeed( 
          vertex=2 
        ) 
      ], 
      view=g.View( 
        edges=[ 
          g.ElementDefinition( 
            group="edge" 
          ) 
        ] 
      ) 
    ), 
    g.ToVertices( 
      edge_vertices="DESTINATION" 
    ), 
    g.ToSet() 
  ] 
)

Result:

Java
JSON
2
4
3
5
[ 2, 4, 3, 5 ]


Extract both source and destination vertices

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final OperationChain<Set<?>> opChain = new Builder()
        .first(new GetElements.Builder()
                .input(new EntitySeed(1), new EntitySeed(2))
                .inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING)
                .view(new View.Builder()
                        .edge("edge")
                        .build())
                .build())
        .then(new ToVertices.Builder()
                .edgeVertices(ToVertices.EdgeVertices.BOTH)
                .build())
        .then(new ToSet<>())
        .build();
{
  "class" : "OperationChain",
  "operations" : [ {
    "class" : "GetElements",
    "input" : [ {
      "class" : "EntitySeed",
      "vertex" : 1
    }, {
      "class" : "EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "ToVertices",
    "edgeVertices" : "BOTH"
  }, {
    "class" : "ToSet"
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements",
    "input" : [ {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 1
    }, {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices",
    "edgeVertices" : "BOTH"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet"
  } ]
}
g.OperationChain( 
  operations=[ 
    g.GetElements( 
      view=g.View( 
        edges=[ 
          g.ElementDefinition( 
            group="edge" 
          ) 
        ] 
      ), 
      include_incoming_out_going="OUTGOING", 
      input=[ 
        g.EntitySeed( 
          vertex=1 
        ), 
        g.EntitySeed( 
          vertex=2 
        ) 
      ] 
    ), 
    g.ToVertices( 
      edge_vertices="BOTH" 
    ), 
    g.ToSet() 
  ] 
)

Result:

Java
JSON
1
2
4
3
5
[ 1, 2, 4, 3, 5 ]


Extract matched vertices

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final OperationChain<Set<?>> opChain = new Builder()
        .first(new GetElements.Builder()
                .input(new EntitySeed(1), new EntitySeed(2))
                .inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING)
                .view(new View.Builder()
                        .edge("edge")
                        .build())
                .build())
        .then(new ToVertices.Builder()
                .useMatchedVertex(ToVertices.UseMatchedVertex.EQUAL)
                .build())
        .then(new ToSet<>())
        .build();
{
  "class" : "OperationChain",
  "operations" : [ {
    "class" : "GetElements",
    "input" : [ {
      "class" : "EntitySeed",
      "vertex" : 1
    }, {
      "class" : "EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "ToVertices",
    "useMatchedVertex" : "EQUAL"
  }, {
    "class" : "ToSet"
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements",
    "input" : [ {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 1
    }, {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices",
    "useMatchedVertex" : "EQUAL"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet"
  } ]
}
g.OperationChain( 
  operations=[ 
    g.GetElements( 
      input=[ 
        g.EntitySeed( 
          vertex=1 
        ), 
        g.EntitySeed( 
          vertex=2 
        ) 
      ], 
      view=g.View( 
        edges=[ 
          g.ElementDefinition( 
            group="edge" 
          ) 
        ] 
      ), 
      include_incoming_out_going="OUTGOING" 
    ), 
    g.ToVertices( 
      use_matched_vertex="EQUAL" 
    ), 
    g.ToSet() 
  ] 
)

Result:

Java
JSON
1
2
[ 1, 2 ]


Extract opposite matched vertices

Using this directed graph:


    --> 4 <--
  /     ^     \
 /      |      \
1  -->  2  -->  3
         \
           -->  5

Java
JSON
Full JSON
Python
final OperationChain<Set<?>> opChain = new Builder()
        .first(new GetElements.Builder()
                .input(new EntitySeed(1), new EntitySeed(2))
                .inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING)
                .view(new View.Builder()
                        .edge("edge")
                        .build())
                .build())
        .then(new ToVertices.Builder()
                .useMatchedVertex(ToVertices.UseMatchedVertex.OPPOSITE)
                .build())
        .then(new ToSet<>())
        .build();
{
  "class" : "OperationChain",
  "operations" : [ {
    "class" : "GetElements",
    "input" : [ {
      "class" : "EntitySeed",
      "vertex" : 1
    }, {
      "class" : "EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "ToVertices",
    "useMatchedVertex" : "OPPOSITE"
  }, {
    "class" : "ToSet"
  } ]
}
{
  "class" : "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations" : [ {
    "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements",
    "input" : [ {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 1
    }, {
      "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed",
      "vertex" : 2
    } ],
    "view" : {
      "edges" : {
        "edge" : { }
      }
    },
    "includeIncomingOutGoing" : "OUTGOING"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices",
    "useMatchedVertex" : "OPPOSITE"
  }, {
    "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet"
  } ]
}
g.OperationChain( 
  operations=[ 
    g.GetElements( 
      view=g.View( 
        edges=[ 
          g.ElementDefinition( 
            group="edge" 
          ) 
        ] 
      ), 
      input=[ 
        g.EntitySeed( 
          vertex=1 
        ), 
        g.EntitySeed( 
          vertex=2 
        ) 
      ], 
      include_incoming_out_going="OUTGOING" 
    ), 
    g.ToVertices( 
      use_matched_vertex="OPPOSITE" 
    ), 
    g.ToSet() 
  ] 
)

Result:

Java
JSON
2
4
3
5
[ 2, 4, 3, 5 ]


results matching ""

    No results matching ""