27.6.1 Creating a Partitioned Graph Using the GraphBuilder Interface
The createGraphBuilder()
API supports the creation of partitioned
graphs.
The graph partitioning strategy is based on labels. Each vertex and edge in the graph can have only one label. Vertices with the same label will be grouped together into the same vertex provider. The name of the vertex provider will be same as the vertex label. Similarly, edges with the same label, source provider, and destination provider are grouped into a single edge provider. The edge provider name is constructed by concatenating the edge label, source provider name, and destination provider name as shown in the following format:
edgeLabel_sourceProviderName_destinationProviderName
Every element within the same provider will have the same list of properties. If the properties do not have a specific value, then a default value will be used.
The two important configuration options that impact how vertices and edges are processed
when using the GraphBuilder
API are:
- ID Generation Strategy: This determines how IDs are generated for vertices
and edges during graph construction. The
GraphBuilder
supports two ID generation strategies:USER_IDS
: As a user, you can provide the IDs for vertices and edges.Note that the user-provided IDs must be unique for vertices and edges. This implies that you cannot add two vertices or edges with the same ID, even if they belong to different partitions. This uniqueness constraint is enforced regardless of the ID strategy to be adopted later by the created graph.
AUTO_GENERATED
: The system automatically generates the IDs for vertices and edges.
- ID Strategy: This determines how the graph manages and accesses
vertex and edge IDs after creation. This ID strategy is independent of how the IDs
were generated during graph creation (either autogenerated
(
AUTO_GENERATED
) or specified by you (USER_IDS
) ). You can then choose to retain these IDs or not in the final graph for both vertices and edges by using thesetRetainVertexIds
orsetRetainEdgeIds
API respectively. Depending on whether the vertex and edge IDs are preserved or not, the final graph strategy for vertex and edge IDs will be one of the following:-
KEYS_AS_IDS
PARTITIONED_IDS
UNSTABLE_GENERATED_IDS
The following topics explain the different ID strategies in detail:
-
- KEYS_AS_IDS Strategy
KEYS_AS_IDS
strategy implies that IDs are based on user-provided keys. In this case, IDs must be globally unique across the entire graph. - PARTITIONED_IDS Strategy
PARTITIONED_IDS
strategy implies that IDs are constructed by combining the label name with user-provided keys or auto-generated keys. Therefore, the uniqueness requirement for IDs applies at the label level once the graph is built. - UNSTABLE_GENERATED_IDS Strategy
UNSTABLE_GENERATED_IDS
strategy implies that the IDs are system-generated and may change. These IDs are not guaranteed to be stable.
Parent topic: Graph Builder and Graph Change Set