15.9.5.6 Combining Filter Expressions
Any filter expression used for subgraph filtering, can be combined with any other filter expression to form a new filter expression.
Filters can be combined using the following operations:
- intersection
- union
Note:
The intersection of two filters will not behave as anAND
in the filter expression.
Note:
The union of filters will not behave as anOR
in the filter expression.
In the following example an edge filter is intersected with a vertex filter. The resulting subgraph will only include vertices that have the name 'PGX
' and will only include edges that have a cost greater than 5
.
opg-jshell> var edgeFilter = EdgeFilter.fromExpression("edge.cost > 5") opg-jshell> var vertexFilter = VertexFilter.fromExpression("vertex.name = 'PGX'") opg-jshell> var combinedFilter = edgeFilter.intersect(vertexFilter)
EdgeFilter edgeFilter = EdgeFilter.fromExpression("edge.cost > 5"); VertexFilter vertexFilter = VertexFilter.fromExpression("vertex.name = 'PGX'"); GraphFilter combinedFilter = edgeFilter.intersect(vertexFilter);
edge_filter = EdgeFilter("edge.cost > 5") vertex_filter = VertexFilter("vertex.name = 'PGX'") combined_filter = edge_filter.intersect(vertex_filter)
In contrast, the subgraph created by the union of those filters will include vertices that either have the name 'PGX
' or that has an incoming or outgoing edge with a cost greater than 5
. It will also include edges with a cost greater than 5
, as well as edges for which the source and destination vertex have the name 'PGX
'.
Parent topic: Operations on Filter Expressions