Graph Studio Tutorial (4/6)

Build your First Graph using the Python API

Pablo Sierra
3 min readAug 17, 2022

Previous chapter,

← Graph Studio Setup— |

Now is moment to build our first graph!

In Graph Studio, you can look for the notebook icon in the left side menu and create a new notebook.

Inside the notebook exists some cells types a one of those are Python cells who starts with %python-gpx.

In this kind of code block you can write valid python code (awesome!!!).

For example:

Code explanation:

  • First, you need create a kind of “builder graph constructor” . In order to do that the session runtime is part of the python API core and is automatically available for our full notebook environment.
  • Second, with builder you can create the graph structure based on nodes a, b, c with their ID’s 1, 2, 3 respectively and the edges.

The properties and labels are omitted for now.

  • Third, you can omit safely the optional block of code in the very first time, but, if you want to play around the code running It in multiple times, It is required.

One alternative here is, change the graph name for every execution, for example, “graph_2” for the second one and so on.

  • Finally, the build method takes the name of the graph, in this case “graph”, but, you can name It as you want.

Write the code above, click on the run button in the cell located at the upper right side and the final view in the graph studio looks like:

The print line show the number of vertices(v) and edges(e) in the Graph.

Remember, vertices and nodes are the same thing.

In the very first time this run action cannot be immediately, because in the background the environment must be Attached.

You can check the current Environment status a take actions in the menu:

--

--

Pablo Sierra

Solution Architect with expertise in artificial intelligence (AI), analytics, and Oracle Cloud solutions.