Creating vertices and edges in DataStax Studio
-
DSE 5.1 installed, configured, and running.
-
DataStax Studio installed and running.
-
A connection from Studio to a DSE cluster.
Add Gremlin code to a notebook to create a simple two vertex, one edge graph.
-
If necessary, start DataStax Studio and open the notebook you previously created.
-
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. -
Add a cell to the notebook.
-
Ensure that Gremlin is selected in the menu for the notebook cell editor mode:
-
Add the code to the cell to create some vertices and edges for the graph.
schema.config().option('graph.schema_mode').set('Development') 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) g.V()
These lines of code, put DSE Graph in development mode, create two vertices, and connect them with a single edge.
-
Select Run Cell to execute the code.
-
Select Graph in Display toolbar. (By default, the Table view is displayed.)
My first graph -
Hover your mouse over a vertex to display its properties.
See the DSE Graph documentation.