xgi-org / xgi

CompleX Group Interactions (XGI) is a Python package for higher-order networks.
https://xgi.readthedocs.io
Other
185 stars 30 forks source link

add format to `add_nodes_from` #342

Open nwlandry opened 1 year ago

nwlandry commented 1 year ago

A natural input type to support would be a dictionary, e.g.,

H = xgi.Hypergraph()
H.add_nodes_from({1, {"name": "a"}, 2: {"name": "b"}, 3: {"name": "c"}, 4: {"name": "d"}})

This input type currently works but doesn't add any of the attributes.

leotrs commented 1 year ago

I have Opinions about add_nodes_from and add_edges_from. They are long and convoluted functions precisely because they accept way too many similar-but-not-quite-the-same formats. At some point we should choose 1-3 formats and stick to them, and ask the users to transform their data into one of those formats rather than try to cover all possiblecases.

maximelucas commented 1 year ago

What is the way right now to add attributes to nodes?

add_edges_from is definitely long and convoluted but I'm not sure add_nodes_from is (how many formats do we allow there?)?

leotrs commented 1 year ago

add_edges_from is definitely long and convoluted but I'm not sure add_nodes_from is (how many formats do we allow there?)?

Ah you're right! Okay then let's prevent it from becoming convoluted :)