-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Representation of self-loops and the calculation of degrees #17
Comments
We are working on this. |
commit a99b4f6 to devel branch of https://git.bioconductor.org/packages/graph corrects the computation of degree for graphNEL with self-loops. This is version 1.79.2 of graph package. Unit tests are added, documentation not modified yet. |
Dear @vjcitn this commit seems to be the responsible for breaking qpgraph. A minimal reproducible example of the problem is the following: library(graph)
g <- graphBAM(data.frame(from=letters[1:10], to=letters[2:11], weight=rep(1, 10)))
degree(g, letters[1:2])
a b c d e f g h i j k
1 2 1 2 1 2 1 2 1 2 1
Warning message:
In deg + nself :
longer object length is not a multiple of shorter object length Note two things here, one is that I've tracked down the problem to the 216-218 lines of code in the file nself = sapply(1:length(nl),
function(i) sum(names(nl)[i] == nl[[i]]))
names(nself) = names(nl)
return(deg + nself) where the nself <- sapply(Nodes, function(n) sum(n == nl[[n]]))
return(deg + nself) I have checked in my computer that with this update, the |
Thanks Robert. I will commit your fix shortly. Can you suggest a unit test possibly conditionally involving qpgraph that I could include? |
Please try with commit 2f5f89a |
Thanks for porting the fix quickly, I've tried out and works as expected, qpgraph doesn't break anymore. I'll be happy to suggest a unit test involving qpgraph, but probably the best way to do it would be through a PR and at the moment your fix is only available at the Bioc Git server (git.bioconductor.org). Once you synchronize the Bioc Git server repo with the GitHub repo, I'll do the PR. |
It has been synchronized. Thanks. |
This is a verbatim copy of the post I wrote here.
I am writing to ask whether the
graphNEL
class of the graph package supports self-loops. If yes, how should self-loops in undirected graphs be represented? Should they appear once or twice in the adjacency list?As an example, consider the following way to construct a graph:
The undirected graph I intend to represent is the following:
I.e., there are two connected vertices, and one of them has a single-self loop.
B
has degree 1 andA
has degree 3. However, the degree function indicates a degree of 2 forA
:Is this intentional or is it a bug? If intentional, this would be a highly unusual definition for the idea of "degree" that does not possess many of the usual properties of the more commonly known degree concept. For example, the degrees no longer sum up to twice the number of edges. Such a definition is not invalid, but it is unusual enough that it should be pointed out explicitly in the documentation.
Or is it perhaps the case that self-loops are supposed to be included twice in the adjacency list when creating undirected graphs?
It would be great if these issues could be clarified in the documentation.
This issue came up while investigating a bug report for igraph's
as_graphnel()
function: igraph/rigraph#575The text was updated successfully, but these errors were encountered: