Connect G.V() to Aerospike Graph
This page guides you through loading sample data into AGS and connecting G.V() to visualize it. You will run a data loading script to populate the graph, then configure G.V() to connect to AGS.
Load sample data
The Java and Python demos from the basics tutorials drop all data after running queries. To visualize the data in G.V(), you need to reload it and keep it persisted.
-
Navigate to the Python basic example directory.
Terminal window cd aerospike-graph/python/basic -
Create a modified script that loads data without cleanup.
Create a file named
load_data.pywith the following content:import randomimport datetimefrom gremlin_python.process.anonymous_traversal import traversalfrom gremlin_python.driver.driver_remote_connection import DriverRemoteConnectionHOST = "localhost"PORT = 8182def convert_timestamp_to_long(date):timestamp = datetime.datetime.now().timestamp()return int(timestamp)def main():print("Connecting to Aerospike Graph Service...")cluster = DriverRemoteConnection(f"ws://{HOST}:{PORT}/gremlin", "g")g = traversal().with_remote(cluster)if g.inject(0).next() != 0:print("Failed to connect to graph instance")exit()print("Connected to Aerospike Graph Service; Adding Data...")# Add Usersuser1 = g.add_v("User").property("userId", "U1").property("name", "Alice").property("age", 30).next()user2 = g.add_v("User").property("userId", "U2").property("name", "Bob").property("age", 35).next()user3 = g.add_v("User").property("userId", "U3").property("name", "Charlie").property("age", 25).next()user4 = g.add_v("User").property("userId", "U4").property("name", "Diana").property("age", 28).next()user5 = g.add_v("User").property("userId", "U5").property("name", "Eve").property("age", 32).next()# Add Accountsaccount1 = g.add_v("Account").property("accountId", "A1").property("balance", 5000).next()account2 = g.add_v("Account").property("accountId", "A2").property("balance", 3000).next()account3 = g.add_v("Account").property("accountId", "A3").property("balance", 4000).next()account4 = g.add_v("Account").property("accountId", "A4").property("balance", 2000).next()account5 = g.add_v("Account").property("accountId", "A5").property("balance", 6000).next()# Link Users to Accountsg.add_e("owns").from_(user1).to(account1).property("since", "2020").iterate()g.add_e("owns").from_(user2).to(account2).property("since", "2021").iterate()g.add_e("owns").from_(user3).to(account3).property("since", "2022").iterate()g.add_e("owns").from_(user4).to(account4).property("since", "2023").iterate()g.add_e("owns").from_(user5).to(account5).property("since", "2024").iterate()# Add sample transactionsrandom.seed(42)for i in range(1, 51):accounts = g.V().has_label("Account").sample(2).to_list()if len(accounts) < 2:continueamount = random.randint(1, 1000)transaction_id = f"T{i}"type_ = "debit" if random.choice([True, False]) else "credit"timestamp = f"2025-{random.randint(1, 12):02d}-{random.randint(1, 28):02d}"g.add_e("Transaction") \.from_(accounts[0]).to(accounts[1]) \.property("transactionId", transaction_id) \.property("amount", amount) \.property("type", type_) \.property("timestamp", convert_timestamp_to_long(timestamp)) \.iterate()print("Data loaded successfully. Graph is ready for visualization.")cluster.close()if __name__ == "__main__":main() -
Run the data loading script.
Terminal window python load_data.pyConnecting to Aerospike Graph Service...Connected to Aerospike Graph Service; Adding Data...Data loaded successfully. Graph is ready for visualization.Expected result Verify: The script prints
Data loaded successfullyand exits without errors.
Connect G.V() to AGS
Now connect G.V() to your running AGS instance to visualize the loaded data. G.V() uses a connection wizard that guides you through four steps: Hostname Valid, Network Connectivity, Gremlin Compatibility, and Submit Connection.
-
Launch G.V() on your computer.
Open the G.V() application from your Applications folder (macOS), Start menu (Windows), or by running the AppImage (Linux).
-
Open the connection dialog.
Click the Connect button in the toolbar or select File > New Connection from the menu. The “Add a new Graph Database Connection” wizard opens.
-
Configure the initial connection settings.
Enter the following connection details:
Field Value Graph Database Type Aerospike Graph Database Hostname localhost Port 8182 (auto-populated) The hostname field shows a “WS” prefix indicating WebSocket protocol.
-
Test the connection.
Click TEST CONNECTION to verify connectivity. G.V() validates the connection through four steps:
- Hostname Valid
- Network Connectivity
- Gremlin Compatibility
- Submit Connection
Verify: All four steps in the progress indicator turn green with checkmarks, and you see the message “Connection to localhost established successfully. Click on Submit to continue.”
-
Configure the connection details.
After a successful connection test, additional fields appear:
Field Value Connection name localhost (or your preferred name) Connection Color Optional - choose a color to identify this connection Data Model Loading Method Bulk (recommended for graphs with less than 1 million elements) -
Submit the connection.
Click SUBMIT to save the connection and connect to AGS.
Verify: G.V() shows a connected status in the connection panel. The query editor becomes active.
-
Test the connection with a simple query.
In the sidebar under your localhost connection, click New Query to open a query editor tab. Enter the following query:
g.V().count()Click the green play button in the toolbar to execute the query, or press Cmd+Enter (macOS) or Ctrl+Enter (Windows/Linux).
10Expected result Verify: The JSON Output section displays
10, representing the 5 User vertices and 5 Account vertices you loaded. The status bar shows the query execution time.
You are now connected to AGS and ready to run queries and visualize your graph data.