Prevent duplicate edges in Lightrag graph

- Check for reverse edge existence
This commit is contained in:
yangdx
2025-03-17 22:54:23 +08:00
parent 5e1c9f93ca
commit 07b13ee739

View File

@@ -578,6 +578,9 @@ const useLightrangeGraph = () => {
if (sigmaGraph.hasEdge(newEdge.source, newEdge.target)) { if (sigmaGraph.hasEdge(newEdge.source, newEdge.target)) {
continue; continue;
} }
if (sigmaGraph.hasEdge(newEdge.target, newEdge.source)) {
continue;
}
// Add the edge to the sigma graph // Add the edge to the sigma graph
newEdge.dynamicId = sigmaGraph.addDirectedEdge(newEdge.source, newEdge.target, { newEdge.dynamicId = sigmaGraph.addDirectedEdge(newEdge.source, newEdge.target, {