GeezerVison is showing github.com — [pyos][io] Conversion to NetworkX drops isolated vertices · Issue #475 · python-graphblas/python-graphblas
[pyos][io] Conversion to NetworkX drops isolated vertices #475DescriptionWhen converting to NetworkX, isolated vertices are dropped. Example:
M=gb.Matrix.from_edgelist([(0,1),(3,0)],nrows=5,ncols=5)
G=gb.io.to_networkx(M)
G.nodes gives NodeView((0, 1, 3)). Nodes 2 and 4 are both missing. This issue also affects viz.draw(). I do understand that it is one way to handle non-square matrices ...
Is this intentional or a bug? It is at least very surprising, and if intentional, it should be clearly documented.
Part of: pyOpenSci/software-submission#81 Reacted by Sultan Orazbayev ActivitySultanOrazbayev commented on Jun 26, 2023 Thank you for raising this!
By creating isolates in networkx for empty rows/cols, we'd be making an assumption that such nodes exist. (edit: for example, in networkx, creating a graph by adding edges [(0,1), (3,0)] would not create nodes 2 and 4, though I understand this is not exactly apples to apples comparision here).
As such, this could be an additional convenience feature (as an additional kwarg such as create_isolates=True). Definitely something that can be documented. added a commit that references this issue on Jun 26, 2023This issue will close once commit 8f03411 is merged into the 'main' branch.8f03411 szhorvat commented on Jun 26, 2023
for example, in networkx, creating a graph by adding edges [(0,1), (3,0)] would not create nodes 2 and 4, though I understand this is not exactly apples to apples comparision here
Indeed these are not comparable concepts. In your example, 0, 1 and 3 are not vertex indices. They are just "names". They might as well be "foo", (2,3) and 3.14.
In comparison, in python-graphblas we have indices: 1st row (index 0), second row (index 1), etc.
The current behaviour is not treating the python-graphblas matrix as an adjacency matrix when converting to a graph. An n-vertex graph has n-by-n adjacency matrix. Instead, a rather idiosyncratic conversion method is used. Reacted by Sultan Orazbayev eriknw commented on Jul 11, 2023 We discussed this and #476 in a recent meeting. I don't recall whether we got consensus, but there is an argument to be made that the nodes should always be added or at least be added by default. Thanks for raising this issue @szhorvat!
Converting GraphBLAS objects to and from graph objects from other libraries is something we'd like to tackle this year, so I think this issue is related to #398. Defining node attributes with a vector could also make sense. Reacted by Sultan Orazbayev
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|