GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #475

New issue
Copy link
New issue
Copy link
Open
#646
#476
Open
[pyos][io] Conversion to NetworkX drops isolated vertices#475
#646
#476
Copy link

Description

@szhorvat
szhorvat
opened on Jun 25, 2023
Issue body actions

When 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

Activity

  1. SultanOrazbayev commented on Jun 26, 2023

    @SultanOrazbayev
    SultanOrazbayev
    on Jun 26, 2023
    Member
    More actions

    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.

  2. SultanOrazbayev
    added a commit that references this issue on Jun 26, 2023

    Allow isolate creation during export to networkx.

    This issue will close once commit 8f03411 is merged into the 'main' branch.
    8f03411
  3. szhorvat commented on Jun 26, 2023

    @szhorvat
    szhorvat
    on Jun 26, 2023
    Author
    More actions

    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
  4. eriknw commented on Jul 11, 2023

    @eriknw
    eriknw
    on Jul 11, 2023
    Member
    More actions

    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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.