You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
What aggregation does Weighted_Adjacency assume for COO matrices with repeated coordinates? #903
Does Graph.Weighted_Adjacency assume that occupied coordinates in a SciPy COO matrix are unique?
NetworkX sums parallel edge weights in the numerical adjacency matrix, and its COO export can represent that sum with repeated coordinates. With python-igraph 1.0.0, SciPy 1.18.1 and NetworkX 3.6.1, upper-triangle mode gives different edge weights for the COO matrix and its dense representation. The vertex strengths agree.
The COO input gives two unit-weight edges on (0, 1). The merged and dense inputs each give one edge of weight 2 on that pair. Filtering for edges with weight ≥ 2 therefore retains the pair only in the latter two graphs. The assertion checks that wrapping the NetworkX array as a coo_matrix preserves every row index, column index and value. In a separate check, passing the coo_array directly raised TypeError in both upper and directed modes.
If unique coordinates are an expected precondition, would it make sense to note this in the Weighted_Adjacency docstring? Otherwise, should the sparse matrix and dense array inputs produce the same weighted edges?
Activity
szhorvat commentedon Nov 29, 2026
It seems that there is a bug. Thanks for the report.
Graph.Weighted_Adjacency()should never produce a multigraph. The result should always be simple.How the input matrix is represented—in dense format, or various sparse formats—should not matter.