hooks graph-cluster / graph-mincut always fail (CLI passes wrong args); louvainCommunities returns {} and minCut modularity -3.75 when called correctly · Issue #1217 · ruvnet/RuVector · GitHub
Skip to content

hooks graph-cluster / graph-mincut always fail (CLI passes wrong args); louvainCommunities returns {} and minCut modularity -3.75 when called correctly #1217

Open

Description

@ronmikailov

Summary

ruvector hooks graph-cluster and hooks graph-mincut fail on every input, in both 0.2.25 and 0.3.3:

$ ruvector hooks graph-cluster a.ts b.ts ...   → {"success":false,"error":"graph.nodes is not iterable"}
$ ruvector hooks graph-mincut  a.ts b.ts ...   → {"success":false,"error":"Cannot read properties of undefined (reading 'length')"}

The ruflo-ruvector vector-cluster skill says to run hooks init first. That doesn't help: I ran it in a throwaway repo with the same files and got the same errors.

Root cause (bin/cli.js → dist/core/graph-algorithms.js)

  1. Signature mismatch. The CLI calls louvainCommunities(nodes, edges) / spectralClustering(nodes, edges, k), but both take a single graph built by buildGraph(nodes, edges) ({nodes, edges, adjacency}).
  2. Edge shape mismatch. The CLI builds {source, target, weight}, while buildGraph destructures {from, to, weight}.
  3. Import regex. It only matches from './x' (same directory), so ../x, ./x.js and subpaths produce no edges.
  4. Node identity. Nodes are basename without extension, so two files named bytea.ts in different packages merge into one node.

The algorithms are also wrong when called correctly

With buildGraph and {from,to} edges on 11 real TypeScript files (6 import edges):

louvainCommunities(G) → {}                       (empty, no assignments)
minCut(G)             → {"groups":[["url-validator"],[...10 others]],"cutWeight":0,"modularity":-3.75}
findBridges(G)        → [{backfill→supabase},{backfill→credentials},{bytea→backfill}]   (plausible)

Modularity is bounded to [-0.5, 1], so -3.75 is an arithmetic error.

Expected

Build the graph with buildGraph, use one edge shape, resolve relative imports to full paths, return non-empty Louvain assignments, and keep modularity in range. A test with a known two-community graph would catch all of this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions