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 the setRetainVertexIds or setRetainEdgeIds 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
    It is important to note that the ID strategy is implicitly determined by the GraphBuilder's configuration and you cannot explicitly choose the ID strategy for vertices or edges when creating a graph with the GraphBuilder.

    The following topics explain the different ID strategies in detail: