> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Graph Visualization

> Step-by-step guide to rendering interactive knowledge graphs

A minimal guide to rendering your current knowledge graph to an interactive HTML file with one call.

**Before you start:**

* Complete [Quickstart](getting-started/quickstart) to understand basic operations
* Have some remembered data or any existing knowledge graph

## What Graph Visualization Shows

* Nodes (entities, types, chunks, summaries) with color coding
* Edges with labels and weights; tooltips show extra edge properties
* Interactive features: drag nodes, zoom/pan, hover edges for details

## Code in Action

### Step 1: Create Your Knowledge Graph

```python theme={null}
await cognee.forget(everything=True)

await cognee.remember(
    ["Alice knows Bob.", "NLP is a subfield of CS."],
    self_improvement=False,
)
```

This starts from a clean state, then uses `remember()` to ingest the text and build the graph in one call.

### Step 2: Generate Visualization

```python theme={null}
visualize_graph_path = os.path.join(
    os.path.dirname(__file__), ".artifacts", "graph_after_remember.html"
)
await visualize_graph(visualize_graph_path)
```

This creates an interactive HTML file with your knowledge graph. You can specify a custom path or use the default location.

## Quick Options

### Default Location

```python theme={null}
from cognee.api.v1.visualize.visualize import visualize_graph

# Writes HTML to your home directory by default
await visualize_graph()
```

### Custom Path

```python theme={null}
from cognee.api.v1.visualize.visualize import visualize_graph

# Writes to the provided file path (created/overwritten)
await visualize_graph("./my_graph.html")
```

## Tips

* **Large graphs**: Rendering a very big graph can be slow. Consider building subsets (e.g., smaller datasets) before visualizing
* **Edge weights**: If present, control line thickness; multiple weights are summarized and shown in tooltips
* **Static HTML**: Files are static HTML; you can open them in any modern browser or share them as artifacts

## Additional examples

Additional examples about Graph visualization are available on our [github](https://github.com/topoteretes/cognee/tree/main/examples/guides).

## Full Example

<Accordion title="Latest guide">
  ```python theme={null}
  import asyncio
  import cognee
  import os
  from cognee.api.v1.visualize.visualize import visualize_graph


  async def main():
      # Prune data and system metadata before running, only if we want "fresh" state.
      await cognee.forget(everything=True)

      await cognee.remember(
          ["Alice knows Bob.", "NLP is a subfield of CS."],
          self_improvement=False,
      )

      visualize_graph_path = os.path.join(
          os.path.dirname(__file__), ".artifacts", "graph_after_remember.html"
      )
      await visualize_graph(visualize_graph_path)


  if __name__ == "__main__":
      asyncio.run(main())
  ```
</Accordion>

<Accordion title="Legacy guide">
  ```python theme={null}
  import asyncio
  import cognee
  import os
  from cognee.api.v1.visualize.visualize import visualize_graph


  async def main():
      await cognee.add(["Alice knows Bob.", "NLP is a subfield of CS."])
      await cognee.cognify()

      visualize_graph_path = os.path.join(
          os.path.dirname(__file__), ".artifacts", "graph_visualization.html"
      )
      await visualize_graph(visualize_graph_path)


  if __name__ == "__main__":
      asyncio.run(main())
  ```
</Accordion>

<Note>
  This simple example uses basic text data for demonstration. In practice, you can visualize complex knowledge graphs with thousands of nodes and relationships.
</Note>

<Columns cols={3}>
  <Card title="Core Concepts" icon="brain" href="/core-concepts/overview">
    Understand knowledge graph fundamentals
  </Card>

  <Card title="Custom Data Models" icon="circle-stop" href="/guides/custom-data-models">
    Learn about custom data models
  </Card>
</Columns>
