Overview
Visualizing your knowledge graph helps you:- Understand structure: See how entities and relationships are organized
- Identify clusters: Discover communities and themes in your data
- Debug issues: Spot problems with entity extraction or relationships
- Communicate insights: Share visual representations with stakeholders
Prerequisites
Before visualizing your graph, you need:- A completed GraphRAG index with GraphML snapshots enabled
- Gephi installed on your system
- The Leiden Algorithm plugin for Gephi
Enable GraphML snapshots
GraphML snapshots must be enabled during indexing to generate visualization files.Configure settings.yaml
settings.yaml and ensure GraphML snapshots are enabled:Run the index
graph.graphml file in your output directory.Locate the GraphML file
Visualization workflow
Follow these steps to create a professional graph visualization:1. Import into Gephi
Launch Gephi
Import the GraphML file
- Go to File → Open
- Navigate to your output folder
- Select
graph.graphml - Click Open
2. Install Leiden Algorithm plugin
The Leiden algorithm detects communities in your graph, which is essential for meaningful visualization.Open Plugin Manager
Find Leiden Algorithm
- Click the Available Plugins tab
- Search for “Leiden Algorithm”
- Check the box next to it
- Click Install
Restart Gephi
3. Run statistics
Generate statistics that will help you visualize the graph structure.Calculate Average Degree
- Find Average Degree
- Click Run
- Click Close on the report dialog
Run Leiden Algorithm
- Find Leiden Algorithm
- Click Run
- Configure settings:
- Quality function: Modularity
- Resolution: 1.0
- Click OK
- Close the report when complete
4. Color nodes by cluster
Color-code nodes based on their community membership.Open Appearance panel
Configure node colors
- Click the Nodes tab
- Click Partition (not Ranking)
- Click the color palette icon in the upper right
- Select Cluster from the dropdown
Generate color palette
- Click Palette…
- Click Generate…
- Uncheck Limit number of colors
- Click Generate
- Click OK
Apply colors
5. Resize nodes by degree centrality
Make important nodes (with many connections) larger.Select ranking mode
- Ensure Nodes is selected
- Click Ranking (not Partition)
- Click the sizing icon (three circles of different sizes)
Configure node sizes
- Select Degree from the dropdown
- Set Min size: 10
- Set Max size: 150
Apply sizing
6. Layout the graph
Arrange nodes spatially to reveal structure.Step 1: OpenORD layout
Select OpenORD
Configure settings
- Liquid: 50
- Expansion: 50
- Cooldown: 0
- Crunch: 0
- Simmer: 0
Run layout
- Click Run
- Watch the progress bar
- Click Stop when complete
Step 2: ForceAtlas2 layout
Select ForceAtlas2
Configure settings
- Scaling: 15
- Dissuade Hubs: ✓ checked
- LinLog mode: ✗ unchecked
- Prevent Overlap: ✓ checked
Run layout
- Click Run
- Watch as nodes settle into position
- Click Stop when nodes stop moving significantly
7. Add labels (optional)
Display entity names on the visualization.Show labels
Configure label appearance
- Click the label settings button
- Adjust:
- Font size: Based on your preference
- Show labels: For visible nodes only
- Label color: Black or contrasting color
Resize labels (optional)
Understanding your visualization
Graph elements
Nodes
Edges
Colors
Size
Interpreting patterns
Dense clusters: Topics or themes with many interconnected entities Bridge nodes: Entities connecting different communities (often important cross-cutting concepts) Peripheral nodes: Mentioned infrequently or in isolation Star patterns: Central entities with many direct connections (key people, organizations, or concepts)Export and share
Export as image
Open Preview
Configure preview
- Preset: Default
- Background color: White
- Show labels: As desired
Export
- Click Export: SVG/PDF/PNG
- Choose format (PNG for presentations, SVG for editing)
- Set resolution (high for publications)
- Save file
Export interactive version
Gephi can export interactive web visualizations:- Install the Sigma Exporter plugin
- Go to File → Export → Sigma.js template
- Configure and export to create an interactive HTML visualization
Advanced techniques
Filter by community
Focus on specific communities:Open Filters panel
Add partition filter
- Expand Attributes → Partition
- Drag Cluster to the Queries area
Select communities
Apply filter
Size by other metrics
You can size nodes by different centrality measures:- Betweenness centrality: Nodes that connect different parts of the graph
- Closeness centrality: Nodes close to all others
- Eigenvector centrality: Nodes connected to other important nodes
Multi-level analysis
GraphRAG’s Leiden algorithm creates hierarchical communities. To visualize different levels:- Run Leiden multiple times with different resolution parameters
- Create separate visualizations for each level
- Compare to see how communities nest within each other
Troubleshooting
Graph appears as a dense ball
Graph appears as a dense ball
- Run ForceAtlas2 longer (it may take time to untangle)
- Increase Scaling parameter to 20-30
- Enable Prevent Overlap
- Try Fruchterman Reingold layout instead
Nodes are all the same color
Nodes are all the same color
- Ensure you ran the Leiden Algorithm
- Check that you selected Partition not Ranking
- Verify Cluster appears in the dropdown
- Re-run Leiden if needed
Cannot find graph.graphml file
Cannot find graph.graphml file
- Verify
snapshots.graphml: truein settings.yaml - Re-run indexing with snapshots enabled
- Check the
storage.base_dirsetting for output location
Gephi crashes or runs slowly
Gephi crashes or runs slowly
- Increase Gephi’s memory allocation
- Filter the graph to show fewer nodes
- Use a more powerful machine for large graphs
- Consider sampling your data before indexing
Example workflow summary
Here’s the complete process at a glance:Enable GraphML
Run indexing
Import to Gephi
output/graph.graphmlInstall Leiden plugin
Run statistics
- Average Degree
- Leiden Algorithm (Modularity, Resolution 1.0)
Apply appearance
- Color by Cluster (Partition)
- Size by Degree (10-150)
Layout
- OpenORD (Liquid 50, Expansion 50)
- ForceAtlas2 (Scaling 15, Dissuade Hubs, Prevent Overlap)
Export