14.10.5.7 Creating a Subgraph Using Filter Expressions with Partitioned IDs

You can create a subgraph using filter expressions with partitioned IDs.

For example, the following creates a subgraph that contains only a single vertex with ID Account(1):

opg4j> PgxGraph subgraph = g.filter(VertexFilter.fromExpression("vertex = 'Accounts(1)'"))
subgraph ==> PgxGraph[name=sub-graph_26,N=1,E=0,created=1630414040396]
PgxGraph subgraph = g.filter(VertexFilter.fromExpression("vertex = 'Accounts(1)'"));
subgraph = graph.filter(VertexFilter.from_expression("vertex = 'Accounts(1)'"))

The following example creates a subgraph that contains only a single edge with ID Transfers(1), and two accompanying vertices:

opg4j> PgxGraph subgraph = g.filter(EdgeFilter.fromExpression("edge = 'Transfers(1)'"))
subgraph ==> PgxGraph[name=sub-graph_27,N=2,E=1,created=1630414144529]
PgxGraph subgraph = g.filter(EdgeFilter.fromExpression("edge = 'Transfers(1)'"));
subgraph = graph.filter(EdgeFilter.from_expression("edge = 'Transfers(1)'"))