Weighted k-cores: missing peeling step, index offset, granularity cap, NaN weights on 2-column files
- Dominant language
- Python
- Stars
- 8
- Forks
- 0
- Avg merge
- 6h 10m
- Merged PRs (30d)
- 16
Description
Found by the September 2026 comparison against the C++ sources (see docs/migration-from-cpp.md on branch docs/legacy-heritage (PR #17)).
`decomposition/kcores.py` `_compute_weighted_cores` only bins each node's total strength into the p-function. The C++ (`graph_kcores.cpp` findCores weighted branch + `vertex.cpp` getP) then peels: for each shell in ascending order, every higher-index neighbour is re-evaluated with its strength restricted to neighbours still above the current shell, and moved down to `max(newP, shell)`. Without that step the result is a strength histogram, not a core decomposition (23/40 nodes differ on a small random test graph, and Python spreads them over 5 indices where the C++ collapses them to 2).
Also:
- The C++ pushes `0.0` twice into the p-function for `equalNodesPerInterval` and `equalIntervalSize`, so its indices run 2..gr+1; Python runs 1..gr. Decide which convention to keep and document it.
- Default granularity: C++ uses the maximum degree; Python caps it at 100.
- `custom` intervals from a file (`-strengthsIntervals custom -strengthsIntervalsFile`) are not ported.
- `maximum_strength` is not exposed on the CLI.
- Weighted detection sniffs a `weight` attribute on the first 100 edges instead of honouring `--weighted`; for a MultiGraph the check reads the key dict and always says unweighted.
- `--weighted` on a two-column file produces NaN weights and every node gets index 2 (C++ treated missing weights as 1.0).
Contributor guide
Research direction
Start with decomposition/kcores.py and _compute_weighted_cores, then compare its behavior with the weighted branches in graph_kcores.cpp and getP in vertex.cpp. Read docs/migration-from-cpp.md and reproduce the small random graph and two-column-file cases mentioned in the issue. Done means the Python decomposition and CLI handle peeling, index conventions, granularity, custom intervals, weight selection, MultiGraph detection, and missing weights consistently with the chosen documented convention.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- cli, data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100