rigraph icon indicating copy to clipboard operation
rigraph copied to clipboard

undirected graph from adjacency matrix without symmetric matrix

Open adfi opened this issue 8 years ago • 4 comments

The docs say the following when mode is "undirected" (and weighted =TRUE):

First we check that the matrix is symmetric. It is an error if not. Then only the upper triangle is used to create a weighted undirected graph.

But the following code (adapted from the example) runs just fine: adjm <- matrix(runif(100), 10) adjm[ adjm<0.5 ] <- 0 graph_from_adjacency_matrix(adjm, weighted=TRUE, mode="undirected")

The example does force a symmetric matrix through (adjm + t(adjm))/2. When looking at the documentation the function graph.adjacency.sparse has a check for symmetry but the function graph.adjacency.dense does not.

Obviously nothing is lost as in with or without a symmetric matrix the result is the same. The question is whether this is intentional and if the docs need to be updated.

adfi avatar Mar 21 '17 14:03 adfi

The code is wrong, graph.adjacency.dense should check for symmetry.

gaborcsardi avatar Mar 21 '17 14:03 gaborcsardi

Thx, I'll create a pull request (unless you've already changed it)

adfi avatar Mar 21 '17 15:03 adfi

PR is welcome! Thanks!

gaborcsardi avatar Mar 21 '17 16:03 gaborcsardi

Okay, I have a patch for this now but I'll hold it off until 1.3.2 is out because this can potentially break reverse dependencies if they happened to use a non-symmetric weighted adjacency matrix (and I don't feel like waiting another 1.5 days to re-run all revdep checks now).

ntamas avatar Jun 13 '22 12:06 ntamas

I believe we handle this better in igraph 1.6.0 and in the current mainline. Do we need to take further action?

krlmlr avatar Jan 02 '24 20:01 krlmlr