A SciPy Laplacian diagonal of -56: a correct degree written into a narrow buffer
Even a correct degree of 200 can be lost when assigned to a narrow work matrix. Compare the original-edge reference with the actual diagonal.
What a wider result type cannot establish
When a graph is retained and reused by several analysis teams, its degree definition should travel with its dtype. First establish whether each Laplacian diagonal preserves the sum of the original edge weights. A table containing those two values gives Truthound Core a bounded comparison to perform. An int64 result type alone is insufficient grounds for admitting the graph calculation. [1, 2, 3]
The versions actually covered by the report
The original SciPy #26549 report distinguishes execution on SciPy 1.17.0 from inspection of 1.18.1 source. It reports a dense int8 Laplacian diagonal of -56 instead of 200 despite requesting int64. A follow-up clarifies that the degree sum is correctly 200: assignment to the int8 work buffer loses it before the final cast. The follow-up execution on 1.18.1 is the contributor’s report, not this article’s independent test. [1]
Build the reference from the edge ledger
Record the input dtype, directedness, self-loop policy, and original edges for each vertex. Use a separate integer calculation with adequate range to derive the expected degree, then join it to the observed diagonal by matrix_id and vertex_id. Positional joins can silently pair different graphs or vertex orders. Hold clustering or anomaly results that use a mismatching Laplacian while testing input promotion or another computation path. [1, 3]
The reference 200 comes from the edges
In an illustrative undirected graph, vertex A connects to B and C with weight 100 each and has no self-loop. Its expected degree is therefore 100+100=200, derived from the edge definition. An observed diagonal of 200 passes this vertex's degree comparison. A diagonal of -56 fails against 200; adding the two off-diagonal values of -100 also gives a row sum of -256. This conceptual contract is not an executed test of every vertex or eigenvalue. [1, 3]
The comparison component's role
ColumnPairValidator in Truthound Python SDK 3.3.2 can apply == to nonmissing values in operator-prepared observed_degree and expected_degree columns. Check missing values and absent vertices separately, and verify that the reference accumulation does not itself overflow a narrow integer type. This Core component does not execute SciPy or repair narrow-integer storage. Matching degrees do not guarantee correctness of the entire matrix or safety of the analysis. [1, 2, 3]
Evaluate alternatives against the same vertex contract
Possible alternatives include promoting the input to a wider integer type or using a verified sparse path. Recheck the original-edge reference, all vertex mappings, and any required row sums or downstream residuals for either option. A task with negative weights or a normalized Laplacian needs a different rule. If existing regression tests already cover these conditions, a duplicate audit table may add little value. [1, 3]
Application conditions
Provide original edges, vertex IDs, and an independent degree reference with adequate integer range.
Alternatives
Compare input promotion and a verified sparse path against the original-edge reference.
Limitations
Degree agreement does not establish the entire matrix, its eigenvalues, or validity of the analysis model.
Evidence
- Event checked
- Subject checked
- Modified
