Implementation:Infiniflow Ragflow KnowledgeGraphUtil
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Knowledge_Base |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Graph algorithms for node classification into combos based on edge relationships and community membership.
Description
This utility module provides two approaches for graph node grouping. The Converter class uses a KeyGenerator (sequential a-z keys) and buildDict to classify connected nodes into the same combo by iterating edges and propagating group assignments. The standalone buildNodesAndCombos function takes a different approach: it groups nodes by their first communities array entry, creating combos with UUID identifiers. If no communities exist, a defaultCombo with the defaultComboLabel is created. isDataExist validates graph data presence. KeyGenerator produces sequential alphabetical keys for combo identification.
Usage
Used by ForceGraph to pre-process raw graph data into the nodes+combos structure required by @antv/g6's combo-combined layout.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: web/src/pages/dataset/knowledge-graph/util.ts
- Lines: 1-107
Signature
export const defaultComboLabel = 'defaultCombo';
export class Converter {
buildDict(edges: { source: string; target: string }[]): Record<string, string>;
buildNodesAndCombos(nodes: any[], edges: any[]): { nodes: any[]; combos: any[] };
}
export const isDataExist = (data: any) => boolean;
export const buildNodesAndCombos = (nodes: any[]) => { nodes: any[]; combos: any[] };
Import
import { buildNodesAndCombos, defaultComboLabel, isDataExist } from './util';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| nodes | any[] | Yes | Graph nodes with optional communities array |
| edges | array | Yes (for Converter) | Edge list with source/target |
Outputs
| Name | Type | Description |
|---|---|---|
| nodes | any[] | Nodes augmented with combo assignment |
| combos | any[] | Combo definitions with id and label |
Usage Examples
import { buildNodesAndCombos } from './util';
const { nodes, combos } = buildNodesAndCombos(graphData.nodes);
// Pass to @antv/g6 Graph.setData({ nodes, edges, combos })