Creating a graph in the Gremlin console

Creating a graph in the Gremlin Console.

DataStax Studio creates a graph automatically for each connection that is created. In Gremlin console, a graph must be manually created. In addition to creating the graph, a graph traversal must be aliased to the graph in order to run queries.


  1. Start the Gremlin console.
  2. Create a simple graph with default settings to hold the data.
    gremlin> system.graph('food').create()
    Note: This command is not available if a graph traversal is aliased with the :remote config alias g some_graph.g command. In order to access the system command, reset the alias with :remote config alias reset
  3. Create a graph with non-default replication, systemReplication, and configuration settings:
      replication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3 }").
      systemReplication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3 }").
    CAUTION: For graphs created in multi-datacenter clusters, the DSE database settings must use NetworkTopologyStrategy and a replication factor greater than one. If the graph is created with a replication setting of SimpleStrategy and a replication factor of 1, the graph data will be stored across the multiple datacenters rather than localizing the data in the graph datacenter.
    The default replication strategy for a multi-datacenter graph is NetworkTopologyStrategy, whereas for a single datacenter, the replication strategy will default to SimpleStrategy. The number of nodes will determine the default replication factor:
    number of nodes per datacenter graph_name replication factor graph_name_system replication factor
    1-3 number of nodes per datacenter number of nodes per datacenter
    greater than 3 3 5
  4. 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.
    gremlin> :remote config alias g food.g
  5. A list of all graphs can be retrieved with the following command:
    gremlin> system.graphs()
    ==> food
    ==> test