Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv9e4e70172561
diff --git a/v3/@claude-flow/memory/src/memory-graph.ts b/v3/@claude-flow/memory/src/memory-graph.ts
index 813fcf3d3e..134b1d7280 100644
--- a/v3/@claude-flow/memory/src/memory-graph.ts
+++ b/v3/@claude-flow/memory/src/memory-graph.ts
@@ -264,6 +264,8 @@ export class MemoryGraph extends EventEmitter {
/**
* Compute PageRank scores using the power iteration method.
+ * Handles dangling nodes (no outgoing edges) by redistributing their
+ * rank mass equally across all nodes.
* Returns a map of node ID to PageRank score.
*/
computePageRank(): Map<string, number> {
@@ -282,11 +284,26 @@ export class MemoryGraph extends EventEmitter {
this.pageRanks.set(nodeId, initialRank);
}
+ // Identify dangling nodes (no outgoing edges)
+ const danglingNodes: string[] = [];
+ for (const nodeId of this.nodes.keys()) {
+ const outEdges = this.edges.get(nodeId);
+ if (!outEdges || outEdges.length === 0) {
+ danglingNodes.push(nodeId);
+ }
+ }
+
let iterations = 0;
for (let iter = 0; iter < this.config.pageRankIterations; iter++) {
let maxDelta = 0;
const newRanks = new Map<string, number>();
+ // Compute dangling node rank sum for redistribution
+ let danglingSum = 0;
+ for (const nodeId of danglingNodes) {
+ danglingSum += this.pageRanks.get(nodeId) || 0;
+ }
+
for (const nodeId of this.nodes.keys()) {
let sum = 0;
const incoming = this.reverseEdges.get(nodeId);
@@ -297,7 +314,8 @@ export class MemoryGraph extends EventEmitter {
}
}
- const newRank = (1 - d) / N + d * sum;
+ // Redistribute dangling rank mass equally
+ const newRank = (1 - d) / N + d * (sum + danglingSum / N);
newRanks.set(nodeId, newRank);
maxDelta = Math.max(maxDelta, Math.abs(newRank - (this.pageRanks.get(nodeId) || 0)));
}