Creating a graph

Creating a graph is the first task required to work with DataStax Graph (DSG). A graph corresponds to a Cassandra keyspace. A graph is created in either DataStax Studio or Gremlin console. The replication settings for DataStax Graph are the same as for Cassandra.

Graph creation in DSG 6.8 is different than in previous versions of DSE Graph. Earlier graph creation of Classic graph is included in DSG 6.8 for migration purposes and is deprecated.

DSG can also create a graph using the CQL command CREATE KEYSPACE, or convert a CQL keyspace into a graph using ALTER KEYSPACE. See the CQL commands to create a keyspace as a graph or convert a keyspace into a graph.


  1. Start DataStax Graph. If using Studio, continue to the next step. If using Gremlin console, skip to this step.

  2. DataStax Studio

  3. Install and start Studio.

  4. In DataStax Studio, create a connection to a DSG node in the cluster.

  5. In DataStax Studio, create a notebook. Select the connection created in the last step.

    A blank notebook will open with a single cell. A graph will not yet be created or associated with the notebook.

  6. Create a graph. Note that after a graph is created in Studio, the configuration cannot be changed.

    Studio can create a graph from a number of different places. You can create the graph as the last step during notebook creation, or open a notebook and add a graph. Either way, several choices must be configured. The graph must be given a name, graph type designated, and replication factor settings selected.

    • Graph type: Core is the default graph engine for DataStax Graph 6.8. If a notebook will use graph data created using DataStax Graph 6.7 or earlier, choose Classic as the graph engine. The schema for Core and Classic graphs is different.

    • Replication factor: The default is set to 1. Production clusters and multi-datacenter clusters need a higher replication factor.

    • Replication strategy: The default is NetworkTopologyStrategy. In general, this default is the good option. Once a graph exists, a graph traversal g is configured that will allow graph traversals to be executed. Graph traversals are used to query the graph data and return results. A graph traversal is bound to a specific traversal source which is the standard OLTP traversal engine.

  7. Gremlin console

  8. Start the Gremlin console.

  9. Create a simple graph with default settings, if the graph does not already exist:


    The replication factor is set to a default of 1 and the replication strategy is set to NetworkTopologyStrategy. Graphs created in multi-datacenter clusters must use NetworkTopologyStrategy and a replication factor greater than one, as shown in the next step.

  10. Create a graph with specified settings:

      withReplication("{'class': 'NetworkTopologyStrategy', '<DC_NAME>': 1}").

    As in DataStax Studio, this step configures replication strategy and replication factor. The variable <DC_NAME> must be changed to a valid cluster name. Durable writes are set to TRUE by default. DataStax recommends using the default value.

  11. On the remote Gremlin Server, set the alias for the graph traversal g to the graph traversal specified in food. To run traversals, the graph traversal must be aliased to a graph.

    // Set the specified graph as the active graph
    :remote config alias g food.g

    As with all queries in DSG, if you are using Gremlin console, alias the graph traversal to a graph before running any commands.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,