How-to GuidesGraph Visualization

Graph Visualization Guide

One of Cognee’s most powerful features is its ability to visualize knowledge graphs. This guide explains how to generate, view, and interpret graph visualizations with default setting using NetworkX.

For this you will need to:

GRAPHISTRY_USERNAME=""
GRAPHISTRY_PASSWORD=""

Generating a Graph Visualization

You can generate a visualization of your knowledge graph using the API:

import cognee
from cognee.shared.utils import render_graph
import asyncio
 
async def main():
    # Add some content first
    await cognee.add("Albert Einstein was a theoretical physicist born in Germany.")
    await cognee.add("Einstein developed the theory of relativity.")
    
    # Process the content
    await cognee.cognify()
    
    # Generate the visualization
    await render_graph()
    
    # You will get the URL to graphistry something like:
    # https://hub.graphistry.com/graph/...
 
if __name__ == "__main__":
    asyncio.run(main())

Understanding the Visualization

The graph visualization shows:

Nodes

Nodes represent entities extracted from your content:

  • People: Individuals mentioned in your content (e.g., “Albert Einstein”)
  • Concepts: Abstract ideas or topics (e.g., “Theory of Relativity”)
  • Organizations: Companies, institutions, etc.
  • Locations: Places mentioned in your content
  • Events: Occurrences or happenings
  • Other entities: Various other types of information

Edges

Edges (lines connecting nodes) represent relationships between entities:

  • The label on each edge describes the relationship (e.g., “developed”, “was born in”)
  • The direction of the relationship is indicated by the arrow

Interacting with the Visualization

The visualization is interactive:

  • Zoom: Use the mouse wheel to zoom in and out
  • Pan: Click and drag to move around the graph
  • Select: Click on nodes to highlight their connections
  • Hover: Hover over nodes and edges to see more details
  • Rearrange: Drag nodes to rearrange the layout

Example Interpretation

Let’s interpret a simple example:

  1. You add content about Albert Einstein
  2. The visualization shows:
    • A node for “Albert Einstein” (Person)
    • A node for “Germany” (Location)
    • A node for “Theory of Relativity” (Concept)
    • An edge from Einstein to Germany labeled “was born in”
    • An edge from Einstein to Theory of Relativity labeled “developed”

This visualization helps you understand how different pieces of information are connected in your knowledge graph.

Troubleshooting

If you’re having trouble with the visualization:

  1. Empty graph: Make sure you’ve added content and run cognee.cognify() before generating the visualization
  2. File not found: Check the system folder path and ensure the file exists
  3. Browser security: Some browsers restrict opening local files; try using Firefox or Chrome
  4. Large graphs: For very large graphs, the visualization may be slow; try filtering to include only specific node types

Next Steps