---
title: "Run and visualize queries"
description: "Run Gremlin queries in G.V() and visualize vertices, edges, and properties as interactive graph diagrams."
---

# Run and visualize queries

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

This page shows you how to run Gremlin queries in G.V() and interpret the visual results. You will execute several queries from the Java and Python basics tutorials and see them rendered as interactive graph visualizations.

## Visualize the entire graph

Start by viewing all vertices and edges in your transaction graph.

1.  Enter the following query in the G.V() query editor.
    
    ```groovy
    g.V().limit(100)
    ```
    
    This query returns up to 100 vertices, which is sufficient for your sample dataset.
    
2.  Execute the query.
    
    Click the green **play button** in the toolbar to execute the query, or press **Cmd+Enter** (macOS) or **Ctrl+Enter** (Windows/Linux).
    
    The **Results** tab displays JSON output showing the 10 vertices:
    
    ```json
    [ {
    
      "id" : -1011,
    
      "label" : "User",
    
      "properties" : {
    
        "name" : "Alice",
    
        "userId" : "U1",
    
        "age" : 30
    
      }
    
    },
    
    ...
    
    ]
    ```
    
    Expected result (JSON)
    
    **Verify:** The status bar shows “Vertices: 10 Edges: 0” indicating 10 vertices were returned.
    
3.  View the graph visualization.
    
    Click the **Graph** tab to see the vertices rendered as an interactive network diagram. You should see 5 User vertices (green) and 5 Account vertices (red) displayed on the canvas.
    
    The sidebar shows a legend with vertex counts by label:
    
    -   Account (5)
    -   User (5)
    
     ![G.V() Graph tab with 10 vertices](https://aerospike.com/docs/_astro/gdotvGraphTab.Bml_Ak9c_1Tn2Xe.png)
4.  Customize User vertex labels.
    
    Open the **Customize Graph Styles** panel by clicking the palette icon in the Graph tab toolbar. In the **VERTEX STYLES** tab:
    
    -   Find the **User** row
    -   Click the **Select a caption** dropdown
    -   Select **name** to display user names on the vertices
    
    **Verify:** User vertices now display names (Alice, Bob, Charlie, etc.) instead of the generic “User” label.
    
5.  Customize owns edge labels.
    
    In the **Customize Graph Styles** panel, click the **EDGE STYLES** tab:
    
    -   Find the **owns** row
    -   Click the **Displaying** dropdown
    -   Select **Default (Edge Label)** to show the edge label on the graph
    
    **Verify:** The `owns` edges now display their label, making it clear which edges represent ownership relationships.
    
6.  Expand the graph to show edges.
    
    Right-click on any vertex and select **Load Edges > Load All Edges** to fetch connected edges. Alternatively, run a query to get edges for a specific vertex:
    
    ```groovy
    g.V().has("Account", "accountId", "A1").bothE()
    ```
    
    **Verify:** The visualization now shows edges connecting the vertices. You should see `owns` edges linking a user to an account and `Transaction` edges between accounts.
    
     ![G.V() graph with edges loaded](https://aerospike.com/docs/_astro/gdotvGraphWithEdges.DWVW5AQp_ZPST1v.png)

::: tip
Use the mouse wheel to zoom in and out of the graph visualization. Click and drag to pan across the canvas. Click and drag individual nodes to rearrange the layout.
:::

## Understanding the visualization

G.V() represents graph elements with consistent visual conventions:

| Element | Representation |
| --- | --- |
| Vertices | Circles or nodes, colored by label |
| Edges | Lines connecting vertices, with arrows showing direction |
| Labels | Text near nodes showing the vertex or edge label |

The layout algorithm automatically positions nodes to minimize edge crossings. You can drag nodes to manually arrange them for clarity.

### Inspecting properties

Click on any vertex or edge to view its properties in the properties panel:

-   **Vertices**: Click on a User or Account to see properties like `name`, `userId`, `accountId`, and `balance`.
-   **Edges**: Click on a Transaction or `owns` edge to see properties like `transactionId`, `amount`, `type`, and `timestamp`.

## Visualize transactions from a specific user

Explore Alice’s transaction network by starting from her vertex and expanding outward.

1.  Query for Alice.
    
    ```groovy
    g.V().has("User", "name", "Alice")
    ```
    
2.  Execute the query.
    
    Click the green **play button** in the toolbar to execute the query, or press **Cmd+Enter** (macOS) or **Ctrl+Enter** (Windows/Linux).
    
3.  View the graph and expand connections.
    
    Click the **Graph** tab to see Alice. Right-click on Alice and select **Load Edges > Load All Edges** to show her `owns` edge connecting to her account.
    
    **Verify:** Alice now connects to her Account (A1) via an `owns` edge.
    
     ![G.V() graph with Alice and her account edges loaded](https://aerospike.com/docs/_astro/gdotvGraphAliceWithEdges.BvcIS8Xk_Z21Mbw5.png)
4.  Expand Alice’s account to see transactions.
    
    Right-click on Alice’s account (A1) and select **Load Edges > Load All Edges** to show all Transaction edges.
    
    **Verify:** The visualization shows Transaction edges flowing to and from Alice’s account to other accounts.
    
5.  Customize Account labels for clarity.
    
    Open the **Customize Graph Styles** panel. In the **VERTEX STYLES** tab, find the **Account** row and set the caption to **accountId**.
    
    **Verify:** Account vertices now display their IDs (A1, A2, A3, etc.) instead of the generic “Account” label.
    
     ![G.V() graph with Alice and her account edges loaded](https://aerospike.com/docs/_astro/gdotvGraphAliceWithAccountEdges.BBxvSgzh_1FYSAS.png)

## Run aggregation queries

Aggregation queries return computed values rather than graph elements. G.V() displays these results in the Results tab as JSON.

1.  Enter the aggregation query.
    
    ```groovy
    g.V().hasLabel("Account")
    
      .group()
    
      .by("accountId")
    
      .by(outE("Transaction").values("amount").sum())
    ```
    
    This query groups accounts by their ID and sums the outgoing transaction amounts.
    
2.  Execute the query.
    
    Click the green **play button** in the toolbar to execute the query, or press **Cmd+Enter** (macOS) or **Ctrl+Enter** (Windows/Linux).
    
    ```json
    {
    
      "A1" : 4894,
    
      "A2" : 2656,
    
      "A3" : 4450,
    
      "A4" : 4695,
    
      "A5" : 7187
    
    }
    ```
    
    Expected result
    
    **Verify:** The Results tab displays a JSON map showing each account ID with its total outgoing transaction amount.
    

::: note
Aggregation queries that return maps or primitive values display in the results panel rather than the graph canvas. Only queries that return vertices or edges render as visual elements.
:::
::: undefined
-   I’ve visualized all vertices in the graph.
-   I’ve run a traversal query and viewed the results.
-   I’ve understood how G.V() renders edges and vertices.
:::

[Previous  
Connect G.V() to Aerospike Graph](https://aerospike.com/docs/graph/visualize-your-graph-with-gdotv/step/1/part/1/connect-gdotv) [Next  
Wrap up](https://aerospike.com/docs/graph/visualize-your-graph-with-gdotv/step/2/part/1/wrap-up)