-
Notifications
You must be signed in to change notification settings - Fork 15
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
Wrong network construction for networks with no edges and more than one node #150
Comments
Thank you both for working on this! This is a regression introduced during the addition of the muti-relation networks (somewhere between Instead of simply transposing the data.frame, we should go to use |
Here the gist with my proposed patch: https://gist.github.com/clhunsen/f6332ceac29630476ecbe816839846d8. |
With the merging of PR #149, this can be closed. |
When a network contains no edges but more than one node, all the nodes get combined. To fix this, the respecting data frame, which contains the nodes, has to be transposed. This fixes se-sic#150. Reported-by: Jakob Kronawitter <[email protected]> Signed-off-by: Thomas Bock <[email protected]>
When constructing a network in 'construct.network.from.edge.list', several corner cases need to be handled. When there are no edges available, an empty edge list can be created using 'create.empty.edge.list'. This way, reliably, the function 'igraph::graph.data.frame' can be used to construct a network. This further improves the patch 0d7c222, which tackles se-sic#150. Tests for creating edgeless networks are added to the file 'tests/test-networks.R'. This likely prevents regressions in the future. Additionally, use the function 'create.empty.edge.list' in one further place where possible. Signed-off-by: Claus Hunsen <[email protected]>
Description
When we construct a network which has zero edges and more than one node, all the nodes get combined to one single node.
Thanks to @SCPhantom for pointing this out!
Steps to Reproduce or Minimal Working Example (MWE)
The MWE of @SCPhantom:
./sample/results/testing/sample_feature/feature/commits.list
by the following lines:The resulting network should contain two nodes, namely "D1" and "D2". However, currently there is only one node:
Versions
This affects several versions. I tested it with
v3.4
.Problem & Solution
After debugging the above stated MWE, I identified a bug in line 1041 of
util-networks.R
:https://github.com/se-passau/codeface-extraction-r/blob/83513c701a1cd013aff5ebda152e2b38789d04e3/util-networks.R#L1039-L1042
Here,
nodes.processed
is a data.frame containing the developers "D1" and "D2" as rows (one column). Hence,igraph::vertices(nodes.processed)
treats this column vector as one node (for whatever reason, I did not find anything about that in the documentation of igraph).Solution: Transpose the data.frame! (Use
t
function). The end of line 1041 should look like the following:igraph::vertices(t(nodes.processed))
This solves the problem! We now have two columns and therefore two nodes "D1" and "D2"!
I will provide a patch for that very soon!
The text was updated successfully, but these errors were encountered: