Knowledge Graph Visualization#
RAGFlow exposes graph data in two distinct frontend surfaces: a standalone Knowledge Graph page (legacy GraphRAG) and graph panels embedded inside the Compilation/Artifacts page (Knowledge Compilation Engine, v0.27.0+). These surfaces use different rendering libraries and data sources.
Route Map#
Both views live under the /dataset route prefix :
| Route | Component | Purpose |
|---|---|---|
/dataset/knowledge-graph/:id | pages/dataset/knowledge-graph | Standalone legacy KG view |
/dataset/compilation/:id | pages/dataset/compilation | Compilation artifacts (LLM Wiki + Skills) |
Standalone Knowledge Graph Page#
Entry point: web/src/pages/dataset/knowledge-graph/index.tsx
Renders a single ForceGraph component fed by useFetchKnowledgeGraph() . The delete button triggers useDeleteKnowledgeGraph to remove the entire KG.
Renderer: force-graph.tsx uses Ant Design G6 . Key features:
- Force-directed layout with combo groupings derived from community detection
- Tooltips showing
entity_type,weight, anddescriptionper node/edge - Variable node sizes based on rank; edge weights drive line thickness
- Dark/light theme support
Graph utility logic (node grouping via buildNodesAndCombos) lives in knowledge-graph/util.ts.
Data hook: useFetchKnowledgeGraph() in use-knowledge-request.ts — returns { graph, mind_map } via React Query.
Compilation Page: LlmWiki + Skills Views#
Entry point: web/src/pages/dataset/compilation/index.tsx
The page holds local viewMode state (ViewMode.LlmWiki | ViewMode.Skills) and renders one of two sub-views via a toggle . View modes are defined in constants.ts.
LlmWiki View#
File: llm-wiki-view.tsx
A resizable two-panel layout (left panel defaulting to 33%) :
- Left panel —
WikiLeftPanelwith two tabs: Contents (artifact list nav) and Graph (force graph) - Right panel —
WikiDetailContentshowing the selected artifact's markdown
The left panel's Graph tab renders ArtifactForceGraph fed by useFetchArtifactGraph() . Clicking a graph node calls onSelectArtifact, selecting that wiki page in the right panel.
Cache invalidation: when compilation completes (GenerateStatus.completed), the view invalidates both ArtifactKeys.listByDataset and ArtifactTopicKeys.listByDataset query caches .
Skills View#
File: skills-view.tsx
Also a two-panel resizable layout :
- Left panel —
SkillsLeftPaneldriven byuseCompilationSkill()which fetches a skill tree (DatasetSkillKeys.tree) - Right panel —
MarkdownEditor(read-only) showingskillPage.md_with_weight
Cache invalidation mirrors LlmWiki: DatasetSkillKeys.tree(id) is re-fetched when GenerateType.ToSkills completes .
ArtifactForceGraph Component#
File: web/src/components/artifact-force-graph/index.tsx
Used inside WikiLeftPanel. Unlike the G6-based KG renderer, this is a react-force-graph-2d canvas component. Key details:
useArtifactGraphDatahook transformsIArtifactGraph→GraphData(nodes + links)- Node colors: entities →
#00BEB4, concepts →#4CACFF - Node radius range: 4–14px based on link count
- Accepts
mapNodeToValue,getNodeColor,getNodeRadius, andonNodeClickprops for customization - Auto-fits graph after layout stabilization
Data hook: useFetchArtifactGraph() — optional enabled flag lets WikiLeftPanel defer fetching until the Graph tab is active .
Backend Data Sources#
| Graph type | Backend field / row type | Storage |
|---|---|---|
| Legacy KG (standalone page) | knowledge_graph_kwd = entity/relation/community_report | ES/Infinity (available_int=1) |
| Artifact graph (Compilation page) | artifact_entity, artifact_relation rows built by build_wiki_page_graph() | ES/Infinity |
| Raw graph JSON (structure compile) | knowledge_graph_kwd = "graph", available_int=0 | ES/Infinity (internal only) |
The artifact_entity / artifact_relation rows are materialized during the REFINE phase of the compilation pipeline by build_wiki_page_graph() .
Key Source Files#
| File | Role |
|---|---|
pages/dataset/knowledge-graph/index.tsx | Standalone KG page entry |
pages/dataset/knowledge-graph/force-graph.tsx | G6-based graph renderer |
pages/dataset/compilation/index.tsx | Compilation page, view toggle |
pages/dataset/compilation/llm-wiki-view.tsx | LlmWiki split-panel view |
pages/dataset/compilation/skills-view.tsx | Skills split-panel view |
pages/dataset/compilation/wiki-left-panel/index.tsx | Contents/Graph tab switcher |
components/artifact-force-graph/index.tsx | Shared react-force-graph-2d component |
hooks/use-knowledge-request.ts | useFetchKnowledgeGraph, useFetchArtifactGraph, useFetchArtifactTopicList |
web/src/routes.tsx | Route definitions for both pages |