Graph Databases

Graph databases use graph structures for semantic queries with nodes (vertices), edges (connections), and properties to represent and store data.

Python Example using JanusGraph and Gremlin

"""
graph_database_using_janusgraph.py
demonstrates traversing a graph
"""

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

# Instantiate a graph.
graph = Graph()

# Connect to gremlin.
connection = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g')

# Traverse the graph using the gremlin connection.
g = graph.traversal().withRemote(connection)

# Find a specific node.
herculesAge = g.V().has('name', 'hercules').values('age').next()

# Print the result.
print('Hercules is {} years old.'.format(herculesAge))

# Close the connection.
connection.close()