diff --git a/README.md b/README.md
index e154c719..091b5b77 100644
--- a/README.md
+++ b/README.md
@@ -655,7 +655,7 @@ The `apipeline_enqueue_documents` and `apipeline_process_enqueue_documents` func
This is useful for scenarios where you want to process documents in the background while still allowing the main thread to continue executing.
-And using a routine to process news documents.
+And using a routine to process new documents.
```python
rag = LightRAG(..)
diff --git a/lightrag_webui/src/components/graph/GraphControl.tsx b/lightrag_webui/src/components/graph/GraphControl.tsx
index baa98bfe..aca8a9c4 100644
--- a/lightrag_webui/src/components/graph/GraphControl.tsx
+++ b/lightrag_webui/src/components/graph/GraphControl.tsx
@@ -36,6 +36,8 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean })
const enableEdgeEvents = useSettingsStore.use.enableEdgeEvents()
const renderEdgeLabels = useSettingsStore.use.showEdgeLabel()
const renderLabels = useSettingsStore.use.showNodeLabel()
+ const minEdgeSize = useSettingsStore.use.minEdgeSize()
+ const maxEdgeSize = useSettingsStore.use.maxEdgeSize()
const selectedNode = useGraphStore.use.selectedNode()
const focusedNode = useGraphStore.use.focusedNode()
const selectedEdge = useGraphStore.use.selectedEdge()
@@ -136,6 +138,51 @@ const GraphControl = ({ disableHoverEffect }: { disableHoverEffect?: boolean })
registerEvents(events)
}, [registerEvents, enableEdgeEvents])
+ /**
+ * When edge size settings change, recalculate edge sizes and refresh the sigma instance
+ * to ensure changes take effect immediately
+ */
+ useEffect(() => {
+ if (sigma && sigmaGraph) {
+ // Get the graph from sigma
+ const graph = sigma.getGraph()
+
+ // Find min and max weight values
+ let minWeight = Number.MAX_SAFE_INTEGER
+ let maxWeight = 0
+
+ graph.forEachEdge(edge => {
+ // Get original weight (before scaling)
+ const weight = graph.getEdgeAttribute(edge, 'originalWeight') || 1
+ if (typeof weight === 'number') {
+ minWeight = Math.min(minWeight, weight)
+ maxWeight = Math.max(maxWeight, weight)
+ }
+ })
+
+ // Scale edge sizes based on weight range and current min/max edge size settings
+ const weightRange = maxWeight - minWeight
+ if (weightRange > 0) {
+ const sizeScale = maxEdgeSize - minEdgeSize
+ graph.forEachEdge(edge => {
+ const weight = graph.getEdgeAttribute(edge, 'originalWeight') || 1
+ if (typeof weight === 'number') {
+ const scaledSize = minEdgeSize + sizeScale * Math.pow((weight - minWeight) / weightRange, 0.5)
+ graph.setEdgeAttribute(edge, 'size', scaledSize)
+ }
+ })
+ } else {
+ // If all weights are the same, use default size
+ graph.forEachEdge(edge => {
+ graph.setEdgeAttribute(edge, 'size', minEdgeSize)
+ })
+ }
+
+ // Refresh the sigma instance to apply changes
+ sigma.refresh()
+ }
+ }, [sigma, sigmaGraph, minEdgeSize, maxEdgeSize])
+
/**
* When component mount or hovered node change
* => Setting the sigma reducers
diff --git a/lightrag_webui/src/components/graph/Settings.tsx b/lightrag_webui/src/components/graph/Settings.tsx
index e4085cef..40d02a5e 100644
--- a/lightrag_webui/src/components/graph/Settings.tsx
+++ b/lightrag_webui/src/components/graph/Settings.tsx
@@ -144,6 +144,8 @@ export default function Settings() {
const enableNodeDrag = useSettingsStore.use.enableNodeDrag()
const enableHideUnselectedEdges = useSettingsStore.use.enableHideUnselectedEdges()
const showEdgeLabel = useSettingsStore.use.showEdgeLabel()
+ const minEdgeSize = useSettingsStore.use.minEdgeSize()
+ const maxEdgeSize = useSettingsStore.use.maxEdgeSize()
const graphQueryMaxDepth = useSettingsStore.use.graphQueryMaxDepth()
const graphMaxNodes = useSettingsStore.use.graphMaxNodes()
const graphLayoutMaxIterations = useSettingsStore.use.graphLayoutMaxIterations()
@@ -292,6 +294,40 @@ export default function Settings() {
label={t('graphPanel.sideBar.settings.edgeEvents')}
/>
+
+
{
let rawData: any = null;
@@ -174,6 +180,9 @@ const fetchGraph = async (label: string, maxDepth: number, maxNodes: number) =>
// Create a new graph instance with the raw graph data
const createSigmaGraph = (rawGraph: RawGraph | null) => {
+ // Get edge size settings from store
+ const minEdgeSize = useSettingsStore.getState().minEdgeSize
+ const maxEdgeSize = useSettingsStore.getState().maxEdgeSize
// Skip graph creation if no data or empty nodes
if (!rawGraph || !rawGraph.nodes.length) {
console.log('No graph data available, skipping sigma graph creation');
@@ -204,8 +213,40 @@ const createSigmaGraph = (rawGraph: RawGraph | null) => {
// Add edges from raw graph data
for (const rawEdge of rawGraph?.edges ?? []) {
+ // Get weight from edge properties or default to 1
+ const weight = rawEdge.properties?.weight !== undefined ? Number(rawEdge.properties.weight) : 1
+
rawEdge.dynamicId = graph.addDirectedEdge(rawEdge.source, rawEdge.target, {
- label: rawEdge.properties?.keywords || undefined
+ label: rawEdge.properties?.keywords || undefined,
+ size: weight, // Set initial size based on weight
+ originalWeight: weight, // Store original weight for recalculation
+ })
+ }
+
+ // Calculate edge size based on weight range, similar to node size calculation
+ let minWeight = Number.MAX_SAFE_INTEGER
+ let maxWeight = 0
+
+ // Find min and max weight values
+ graph.forEachEdge(edge => {
+ const weight = graph.getEdgeAttribute(edge, 'originalWeight') || 1
+ minWeight = Math.min(minWeight, weight)
+ maxWeight = Math.max(maxWeight, weight)
+ })
+
+ // Scale edge sizes based on weight range
+ const weightRange = maxWeight - minWeight
+ if (weightRange > 0) {
+ const sizeScale = maxEdgeSize - minEdgeSize
+ graph.forEachEdge(edge => {
+ const weight = graph.getEdgeAttribute(edge, 'originalWeight') || 1
+ const scaledSize = minEdgeSize + sizeScale * Math.pow((weight - minWeight) / weightRange, 0.5)
+ graph.setEdgeAttribute(edge, 'size', scaledSize)
+ })
+ } else {
+ // If all weights are the same, use default size
+ graph.forEachEdge(edge => {
+ graph.setEdgeAttribute(edge, 'size', minEdgeSize)
})
}
diff --git a/lightrag_webui/src/locales/ar.json b/lightrag_webui/src/locales/ar.json
index 5985eed0..73475cea 100644
--- a/lightrag_webui/src/locales/ar.json
+++ b/lightrag_webui/src/locales/ar.json
@@ -157,6 +157,7 @@
"maxNodes": "الحد الأقصى للعقد",
"maxLayoutIterations": "أقصى تكرارات التخطيط",
"resetToDefault": "إعادة التعيين إلى الافتراضي",
+ "edgeSizeRange": "نطاق حجم الحافة",
"depth": "D",
"max": "Max",
"degree": "الدرجة",
diff --git a/lightrag_webui/src/locales/en.json b/lightrag_webui/src/locales/en.json
index c99ae6bb..aa740e64 100644
--- a/lightrag_webui/src/locales/en.json
+++ b/lightrag_webui/src/locales/en.json
@@ -157,6 +157,7 @@
"maxNodes": "Max Nodes",
"maxLayoutIterations": "Max Layout Iterations",
"resetToDefault": "Reset to default",
+ "edgeSizeRange": "Edge Size Range",
"depth": "D",
"max": "Max",
"degree": "Degree",
diff --git a/lightrag_webui/src/locales/fr.json b/lightrag_webui/src/locales/fr.json
index 2c934ce8..2fbf1b6e 100644
--- a/lightrag_webui/src/locales/fr.json
+++ b/lightrag_webui/src/locales/fr.json
@@ -157,6 +157,7 @@
"maxNodes": "Nombre maximum de nœuds",
"maxLayoutIterations": "Itérations maximales de mise en page",
"resetToDefault": "Réinitialiser par défaut",
+ "edgeSizeRange": "Plage de taille des arêtes",
"depth": "D",
"max": "Max",
"degree": "Degré",
diff --git a/lightrag_webui/src/locales/zh.json b/lightrag_webui/src/locales/zh.json
index b4712316..88def36a 100644
--- a/lightrag_webui/src/locales/zh.json
+++ b/lightrag_webui/src/locales/zh.json
@@ -157,6 +157,7 @@
"maxNodes": "最大返回节点数",
"maxLayoutIterations": "最大布局迭代次数",
"resetToDefault": "重置为默认值",
+ "edgeSizeRange": "边粗细范围",
"depth": "深",
"max": "Max",
"degree": "邻边",
diff --git a/lightrag_webui/src/stores/settings.ts b/lightrag_webui/src/stores/settings.ts
index 4f037f78..74513d48 100644
--- a/lightrag_webui/src/stores/settings.ts
+++ b/lightrag_webui/src/stores/settings.ts
@@ -24,6 +24,12 @@ interface SettingsState {
enableHideUnselectedEdges: boolean
enableEdgeEvents: boolean
+ minEdgeSize: number
+ setMinEdgeSize: (size: number) => void
+
+ maxEdgeSize: number
+ setMaxEdgeSize: (size: number) => void
+
graphQueryMaxDepth: number
setGraphQueryMaxDepth: (depth: number) => void
@@ -76,6 +82,9 @@ const useSettingsStoreBase = create()(
enableHideUnselectedEdges: true,
enableEdgeEvents: false,
+ minEdgeSize: 1,
+ maxEdgeSize: 1,
+
graphQueryMaxDepth: 3,
graphMaxNodes: 1000,
graphLayoutMaxIterations: 15,
@@ -132,6 +141,10 @@ const useSettingsStoreBase = create()(
setGraphMaxNodes: (nodes: number) => set({ graphMaxNodes: nodes }),
+ setMinEdgeSize: (size: number) => set({ minEdgeSize: size }),
+
+ setMaxEdgeSize: (size: number) => set({ maxEdgeSize: size }),
+
setEnableHealthCheck: (enable: boolean) => set({ enableHealthCheck: enable }),
setApiKey: (apiKey: string | null) => set({ apiKey }),
@@ -150,7 +163,7 @@ const useSettingsStoreBase = create()(
{
name: 'settings-storage',
storage: createJSONStorage(() => localStorage),
- version: 10,
+ version: 11,
migrate: (state: any, version: number) => {
if (version < 2) {
state.showEdgeLabel = false
@@ -200,6 +213,10 @@ const useSettingsStoreBase = create()(
delete state.graphMinDegree // 删除废弃参数
state.graphMaxNodes = 1000 // 添加新参数
}
+ if (version < 11) {
+ state.minEdgeSize = 1
+ state.maxEdgeSize = 1
+ }
return state
}
}