Graph Filters
PGX Graph filters.
- class pypgx.api.filters.EdgeFilter(filter_expr)
Bases:
GraphFilter
A filter based on an expression that is meant to be evaluated on each edge of the graph.
- Parameters
filter_expr (str) –
- static from_collection(edge_collection)
Instantiate a new edge collection edge filter.
- Parameters
edge_collection (EdgeCollection) – The collection on which the filter acts.
- Raises
TypeError – edge_collection must be a EdgeCollection.
- Returns
The new edge filter.
- Return type
- classmethod from_expression(filter_expression)
Instantiate a new edge filter using an expression.
- Parameters
filter_expression (str) – The edge-filter expression.
- Raises
TypeError – filter_expression must be a VertexCollection.
- Returns
The new filter.
- Return type
- static from_pgql_result_set(result_set, column_name)
Instantiate a new result set edge filter.
- Parameters
result_set (PgqlResultSet) – The result set on which the filter acts.
column_name (str) – The column name to be fetched from the result set.
- Raises
TypeError – result_set must be a PgqlResultSet.
TypeError – column_name must be a string.
- Returns
the new filter
- Return type
- static from_type_and_expression(filter_type, filter_expression)
Instantiate a new filter using an expression and type.
- Parameters
filter_expression (str) – Filter expression.
filter_type (str) – The filter type, can be either “vertex” or “edge”.
- Raises
TypeError – filter_expression must be a string.
ValueError – vertex_filter must be either “vertex” or “edge”.
- Returns
The new filter.
- Return type
Union[VertexFilter, EdgeFilter]
- get_filter_expression()
Fetch the filter expression of the current filter.
- Returns
Filter expression.
- Return type
str
- has_expression()
Check if this GraphFilter object has an expression associated with it.
- Returns
Boolean indicating if the filter has an expression.
- Return type
bool
- intersect(other)
Intersect this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter intersection.
- Return type
- is_binary_operation()
Check if this
GraphFilter
object represents a binary operation.- Returns
True, if this GraphFilter object represents a binary operation.
- Return type
bool
- is_collection_filter()
Check if the filter is using a collection.
- Returns
True if the filter is using a collection.
- Return type
bool
- is_path_finding_filter()
Check if the filter is a path finding filter.
- Returns
True if the filter is a path finding filter.
- Return type
bool
- is_result_set_filter()
Check if the filter is acting on a result set.
- Returns
True if the filter is acting on a result set.
- Return type
bool
- union(other)
Union this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter union.
- Return type
- class pypgx.api.filters.GraphFilter(java_filter)
Bases:
object
A class to filter vertices and/or egdes of a graph.
- static from_type_and_expression(filter_type, filter_expression)
Instantiate a new filter using an expression and type.
- Parameters
filter_expression (str) – Filter expression.
filter_type (str) – The filter type, can be either “vertex” or “edge”.
- Raises
TypeError – filter_expression must be a string.
ValueError – vertex_filter must be either “vertex” or “edge”.
- Returns
The new filter.
- Return type
Union[VertexFilter, EdgeFilter]
- get_filter_expression()
Fetch the filter expression of the current filter.
- Returns
Filter expression.
- Return type
str
- has_expression()
Check if this GraphFilter object has an expression associated with it.
- Returns
Boolean indicating if the filter has an expression.
- Return type
bool
- intersect(other)
Intersect this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter intersection.
- Return type
- is_binary_operation()
Check if this
GraphFilter
object represents a binary operation.- Returns
True, if this GraphFilter object represents a binary operation.
- Return type
bool
- is_collection_filter()
Check if the filter is using a collection.
- Returns
True if the filter is using a collection.
- Return type
bool
- is_path_finding_filter()
Check if the filter is a path finding filter.
- Returns
True if the filter is a path finding filter.
- Return type
bool
- is_result_set_filter()
Check if the filter is acting on a result set.
- Returns
True if the filter is acting on a result set.
- Return type
bool
- union(other)
Union this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter union.
- Return type
- class pypgx.api.filters.PathFindingFilter(graph_filter, source_vertex, destination_vertex)
Bases:
GraphFilter
Class representing a filter that is meant to be evaluated on all vertices/edges on a path between two nodes.
- Parameters
graph_filter (GraphFilter) –
source_vertex (PgxVertex) –
destination_vertex (PgxVertex) –
- static from_type_and_expression(filter_type, filter_expression)
Instantiate a new filter using an expression and type.
- Parameters
filter_expression (str) – Filter expression.
filter_type (str) – The filter type, can be either “vertex” or “edge”.
- Raises
TypeError – filter_expression must be a string.
ValueError – vertex_filter must be either “vertex” or “edge”.
- Returns
The new filter.
- Return type
Union[VertexFilter, EdgeFilter]
- get_filter_expression()
Fetch the filter expression of the current filter.
- Returns
Filter expression.
- Return type
str
- has_expression()
Check if this GraphFilter object has an expression associated with it.
- Returns
Boolean indicating if the filter has an expression.
- Return type
bool
- intersect(other)
Intersect this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter intersection.
- Return type
- is_binary_operation()
Check if this
GraphFilter
object represents a binary operation.- Returns
True, if this GraphFilter object represents a binary operation.
- Return type
bool
- is_collection_filter()
Check if the filter is using a collection.
- Returns
True if the filter is using a collection.
- Return type
bool
- is_path_finding_filter()
Check if the filter is a path finding filter.
- Returns
True if the filter is a path finding filter.
- Return type
bool
- is_result_set_filter()
Check if the filter is acting on a result set.
- Returns
True if the filter is acting on a result set.
- Return type
bool
- union(other)
Union this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter union.
- Return type
- class pypgx.api.filters.ResultSetEdgeFilter(filter_expr)
Bases:
EdgeFilter
Represents an edge filter used to create a edge set out of the PGQL result set.
This is a wrapper storing the column name that will be fetched from the result set and the result set id in addition to what is inside an
EdgeFilter
.- Parameters
filter_expr (str) –
- static from_collection(edge_collection)
Instantiate a new edge collection edge filter.
- Parameters
edge_collection (EdgeCollection) – The collection on which the filter acts.
- Raises
TypeError – edge_collection must be a EdgeCollection.
- Returns
The new edge filter.
- Return type
- classmethod from_expression(filter_expression)
Instantiate a new edge filter using an expression.
- Parameters
filter_expression (str) – The edge-filter expression.
- Raises
TypeError – filter_expression must be a VertexCollection.
- Returns
The new filter.
- Return type
- static from_pgql_result_set(result_set, column_name)
Instantiate a new result set edge filter.
- Parameters
result_set (PgqlResultSet) – The result set on which the filter acts.
column_name (str) – The column name to be fetched from the result set.
- Raises
TypeError – result_set must be a PgqlResultSet.
TypeError – column_name must be a string.
- Returns
the new filter
- Return type
- static from_type_and_expression(filter_type, filter_expression)
Instantiate a new filter using an expression and type.
- Parameters
filter_expression (str) – Filter expression.
filter_type (str) – The filter type, can be either “vertex” or “edge”.
- Raises
TypeError – filter_expression must be a string.
ValueError – vertex_filter must be either “vertex” or “edge”.
- Returns
The new filter.
- Return type
Union[VertexFilter, EdgeFilter]
- get_column_name()
Get the column name.
- Returns
The column name.
- Return type
str
- get_filter_expression()
Fetch the filter expression of the current filter.
- Returns
Filter expression.
- Return type
str
- get_result_set_id()
Get the result set id.
- Returns
The result set id.
- Return type
str
- has_expression()
Check if this GraphFilter object has an expression associated with it.
- Returns
Boolean indicating if the filter has an expression.
- Return type
bool
- intersect(other)
Intersect this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter intersection.
- Return type
- is_binary_operation()
Check if this
GraphFilter
object represents a binary operation.- Returns
True, if this GraphFilter object represents a binary operation.
- Return type
bool
- is_collection_filter()
Check if the filter is using a collection.
- Returns
True if the filter is using a collection.
- Return type
bool
- is_path_finding_filter()
Check if the filter is a path finding filter.
- Returns
True if the filter is a path finding filter.
- Return type
bool
- is_result_set_filter()
Check if the filter is acting on a result set.
- Returns
True if the filter is acting on a result set.
- Return type
bool
- union(other)
Union this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter union.
- Return type
- class pypgx.api.filters.ResultSetVertexFilter(filter_expr)
Bases:
VertexFilter
Represents a vertex filter used to create a vertex set out of the PGQL result set.
This is a wrapper storing the column name that will be fetched from the result set and the result set id in addition to what is inside a
VertexFilter
.- Parameters
filter_expr (str) –
- static from_collection(vertex_collection)
Instantiate a new vertex collection vertex filter.
- Parameters
vertex_collection (VertexCollection) – The collection on which the filter acts.
- Raises
TypeError – vertex_collection must be a VertexCollection.
- Returns
The new filter.
- Return type
VertexCollectionFilter
- classmethod from_expression(filter_expression)
Instantiate a new vertex filter using an expression.
- Parameters
filter_expression (str) – The vertex-filter expression.
- Raises
TypeError – filter_expression must be a string.
- Returns
The new filter.
- Return type
- static from_pgql_result_set(result_set, column_name)
Instantiate a new result set vertex filter.
- Parameters
result_set (PgqlResultSet) – The result set on which the filter acts.
column_name (str) – The column name to be fetched from the result set.
- Raises
TypeError – result_set must be a PgqlResultSet.
TypeError – column_name must be a string.
- Returns
The new filter.
- Return type
- static from_type_and_expression(filter_type, filter_expression)
Instantiate a new filter using an expression and type.
- Parameters
filter_expression (str) – Filter expression.
filter_type (str) – The filter type, can be either “vertex” or “edge”.
- Raises
TypeError – filter_expression must be a string.
ValueError – vertex_filter must be either “vertex” or “edge”.
- Returns
The new filter.
- Return type
Union[VertexFilter, EdgeFilter]
- get_column_name()
Get the column name.
- Returns
The column name.
- Return type
str
- get_filter_expression()
Fetch the filter expression of the current filter.
- Returns
Filter expression.
- Return type
str
- get_result_set_id()
Get the result set id.
- Returns
The result set id.
- Return type
str
- has_expression()
Check if this GraphFilter object has an expression associated with it.
- Returns
Boolean indicating if the filter has an expression.
- Return type
bool
- intersect(other)
Intersect this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter intersection.
- Return type
- is_binary_operation()
Check if this
GraphFilter
object represents a binary operation.- Returns
True, if this GraphFilter object represents a binary operation.
- Return type
bool
- is_collection_filter()
Check if the filter is using a collection.
- Returns
True if the filter is using a collection.
- Return type
bool
- is_path_finding_filter()
Check if the filter is a path finding filter.
- Returns
True if the filter is a path finding filter.
- Return type
bool
- is_result_set_filter()
Check if the filter is acting on a result set.
- Returns
True if the filter is acting on a result set.
- Return type
bool
- union(other)
Union this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter union.
- Return type
- class pypgx.api.filters.VertexFilter(filter_expr)
Bases:
GraphFilter
A filter based on an expression that is meant to be evaluated on each vertex of the graph.
- Parameters
filter_expr (str) –
- static from_collection(vertex_collection)
Instantiate a new vertex collection vertex filter.
- Parameters
vertex_collection (VertexCollection) – The collection on which the filter acts.
- Raises
TypeError – vertex_collection must be a VertexCollection.
- Returns
The new filter.
- Return type
VertexCollectionFilter
- classmethod from_expression(filter_expression)
Instantiate a new vertex filter using an expression.
- Parameters
filter_expression (str) – The vertex-filter expression.
- Raises
TypeError – filter_expression must be a string.
- Returns
The new filter.
- Return type
- static from_pgql_result_set(result_set, column_name)
Instantiate a new result set vertex filter.
- Parameters
result_set (PgqlResultSet) – The result set on which the filter acts.
column_name (str) – The column name to be fetched from the result set.
- Raises
TypeError – result_set must be a PgqlResultSet.
TypeError – column_name must be a string.
- Returns
The new filter.
- Return type
- static from_type_and_expression(filter_type, filter_expression)
Instantiate a new filter using an expression and type.
- Parameters
filter_expression (str) – Filter expression.
filter_type (str) – The filter type, can be either “vertex” or “edge”.
- Raises
TypeError – filter_expression must be a string.
ValueError – vertex_filter must be either “vertex” or “edge”.
- Returns
The new filter.
- Return type
Union[VertexFilter, EdgeFilter]
- get_filter_expression()
Fetch the filter expression of the current filter.
- Returns
Filter expression.
- Return type
str
- has_expression()
Check if this GraphFilter object has an expression associated with it.
- Returns
Boolean indicating if the filter has an expression.
- Return type
bool
- intersect(other)
Intersect this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter intersection.
- Return type
- is_binary_operation()
Check if this
GraphFilter
object represents a binary operation.- Returns
True, if this GraphFilter object represents a binary operation.
- Return type
bool
- is_collection_filter()
Check if the filter is using a collection.
- Returns
True if the filter is using a collection.
- Return type
bool
- is_path_finding_filter()
Check if the filter is a path finding filter.
- Returns
True if the filter is a path finding filter.
- Return type
bool
- is_result_set_filter()
Check if the filter is acting on a result set.
- Returns
True if the filter is acting on a result set.
- Return type
bool
- union(other)
Union this filter with another graph-filter object.
- Parameters
other (GraphFilter) – The other graph-filter
- Raises
TypeError – other argument must be a GraphFilter. It can be an instance of a subclass, such as VertexFilter or EdgeFilter.
- Returns
An object representing the filter union.
- Return type