Graph Studio Tutorial (4/6)
Build your First Graph using the Python API
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!!!).
Get Pablo Sierra’s stories in your inbox
Join Medium for free to get updates from this writer.
For example:
Code explanation:
- First, you need create a kind of “builder graph constructor” . In order to do that the
sessionruntime is part of the python API core and is automatically available for our full notebook environment. - Second, with
builderyou can create the graph structure based on nodesa, b, cwith their ID’s1, 2, 3respectively 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
buildmethod 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:










