Skip to content

Add support for dict-of-dict for add_nodes_from #752

Description

@nwlandry

When I run

H = xgi.Hypergraph()
node_dict = {0: {"name": "tom"}}
H.add_nodes_from(node_dict)

and run H.nodes[0], I get {}.

When I run

H = xgi.Hypergraph()
node_dict = {0: {"name": "tom"}}
H.add_nodes_from(node_dict)
H.set_node_attributes(node_dict)

and run H.nodes[0], I get {"name": "tom"}.

I think that add_nodes_from should have the same effect as running the second code snippen.

In the past, we've talked about limiting the number of input formats that we support, but I think that aside from a list/array of nodes to add, this is the second most useful option.

Activity

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

    new featureNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions