Creating vertices and edges in DataStax Studio

Add Gremlin code to a notebook to create a simple two vertex, one edge graph.

  1. If necessary, start DataStax Studio and open the notebook you previously created.

  2. When you create a notebook, an empty graph instance is created and named after the value in the graph name field in the notebook’s connection. A local variable, g, is defined automatically and bound to that graph.

  3. Add a cell to the notebook.

  4. Ensure that Gremlin is selected in the menu for the notebook cell editor mode:

  5. Add the code to the cell to create some vertices and edges for the graph.

    Vertex firstVertex = graph.addVertex(label, 'user', 'id', 1, 'name', 'Jo Dowe', 'role', 'customer')
    Vertex secondVertex = graph.addVertex(label,'product', 'id', 2, 'name', 'fountain pen')
    firstVertex.addEdge('bought', secondVertex)

    These lines of code, put DSE Graph in development mode, create two vertices, and connect them with a single edge.

  6. Select Run Cell to execute the code.

  7. Select Graph in Display toolbar. (By default, the Table view is displayed.)

    My first graph
  8. Hover your mouse over a vertex to display its properties.

See the DSE Graph documentation.

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,