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" : "uk.gov.gchq.gaffer.operation.impl.output.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(
view=g.View(
entities=[
g.ElementDefinition(
group="entity"
)
],
all_edges=False,
all_entities=False
),
input=[
g.EntitySeed(
vertex=1
),
g.EntitySeed(
vertex=2
)
]
),
g.ToVertices(
edge_vertices="NONE"
),
g.ToSet()
]
)
Result:
Java
JSON
2
1
[ 2, 1 ]
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" : "uk.gov.gchq.gaffer.operation.impl.output.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(
view=g.View(
edges=[
g.ElementDefinition(
group="edge"
)
],
all_edges=False,
all_entities=False
),
input=[
g.EntitySeed(
vertex=1
),
g.EntitySeed(
vertex=2
)
],
include_incoming_out_going="OUTGOING"
),
g.ToVertices(
edge_vertices="DESTINATION"
),
g.ToSet()
]
)
Result:
Java
JSON
4
3
2
5
[ 4, 3, 2, 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" : "uk.gov.gchq.gaffer.operation.impl.output.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"
)
],
all_edges=False,
all_entities=False
),
input=[
g.EntitySeed(
vertex=1
),
g.EntitySeed(
vertex=2
)
],
include_incoming_out_going="OUTGOING"
),
g.ToVertices(
edge_vertices="BOTH"
),
g.ToSet()
]
)
Result:
Java
JSON
1
4
2
3
5
[ 1, 4, 2, 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" : "uk.gov.gchq.gaffer.operation.impl.output.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(
view=g.View(
edges=[
g.ElementDefinition(
group="edge"
)
],
all_edges=False,
all_entities=False
),
input=[
g.EntitySeed(
vertex=1
),
g.EntitySeed(
vertex=2
)
],
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" : "uk.gov.gchq.gaffer.operation.impl.output.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"
)
],
all_edges=False,
all_entities=False
),
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
4
3
2
5
[ 4, 3, 2, 5 ]