Skip to content
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

Save Network: save the same as in NetworkX #275

Open
ajdapretnar opened this issue Jul 15, 2024 · 2 comments
Open

Save Network: save the same as in NetworkX #275

ajdapretnar opened this issue Jul 15, 2024 · 2 comments

Comments

@ajdapretnar
Copy link
Contributor

Network version

1.9.0

Orange version

3.37.0

Expected behavior

Save Network saves the data (attributes) in the same way as etworkX would. See below.
Screenshot 2024-07-15 at 10 32 06

Actual behavior

The data is saved as such. Orange can't read what it saves (attributes not loaded properly). NetworkX can't read what Orange saves. Also, Orange can't read what NetworkX saves.
Uploading Screenshot 2024-07-15 at 10.39.39.png…

Steps to reproduce the behavior

import networkx as nx

Create a graph

G = nx.Graph()

# Add nodes with attributes
G.add_node(1, name='Alice', age="30")
G.add_node(2, name='Bob', age="25")
G.add_node(3, name='Charlie', age="35")
G.add_node(4, name='David', age="40")

# Add edges
G.add_edge(1, 2)
G.add_edge(1, 3)
G.add_edge(2, 3)
G.add_edge(3, 4)

nx.write_pajek(G, "simple_network.net")
Additional info (worksheets, data, screenshots, ...)

While pajek doesn't have a documentation on its format (from what I know), it would be nice to have the format transferable between NetworkX and Orange. Or at the very least for Orange to properly read the data it saves.

@janezd
Copy link
Contributor

janezd commented Jul 16, 2024

This shouldn't be too difficult to implement. A few observations, though.

  • Orange's reader currently ignores everything after coordinates, label, x, y, *_ = parts + [None, None]. This is good; we didn't add any custom data (in the meanwhile Network File and Explorer: Load data for edges; show colored and labelled edges #249 allows giving labels to edges).
  • Networkx seems to allow arbitrary key-value pairs after nodes. In Orange, this would be represented as a Table, hence every key would become a variable, and variable types would be deducted from values, I guess, using the same rules as one-line tab files.
  • Besides key-value pairs, networkx adds a shape (ellipsis). This is probably something like a reserved word. Do you know what are the others?
  • Can you check why Networkx can't read files that are created in Orange? I don't think we're adding anything fancy.

@ajdapretnar
Copy link
Contributor Author

Can you check why Networkx can't read files that are created in Orange? I don't think we're adding anything fancy.

When I said it "can't read files" I was being dramatic. I meant it doesn't handle attributes properly. It takes everything as a node label, i.e. '[544 | G1] {security, G1}'. Ideally, the only node label would be "security", with "544" as node attribute Count (which was present in the original data). And, of course, "G1" would be an attribute Group, so that the user could navigate between attributes properly. Now it is a single item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants