Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #3010.
My colleagues and I ran into this issue when working on an algorithm that sums several sparse adjacency matrices entry-wise, counts overlap and sets entries to zero if they are below a certain threshold. These explicitly stored zeros were interpreted by graph_from_adjacency_matrix() as edges, when materializing the graph.
We traced the issue to a shortcut in the unweighted sparse-matrix conversion. The code checks whether the largest stored value is 1 and, if so, creates one edge for every stored entry. That check also passes when the stored values are c(1, 0), so the zero produces an edge too. I changed the shortcut to check whether all stored values are 1. When a stored zero is present, the code now falls back to the existing logic that uses each value as an edge count.
I added a small test based on the example in the issue. It returned two edges before the change and one afterward, as expected. The adjacency tests ran with zero failures and one skip because pcalg was unavailable.
LLM disclosure: Both Claude and ChatGPT were used to help identify the issue and produce the fix.