hetio / xswap

Python library (C++ backend) for degree-preserving network randomization
https://hetio.github.io/xswap/
BSD 2-Clause "Simplified" License
12 stars 3 forks source link

Tweaks to map_str_edges function #24

Open dhimmel opened 5 years ago

dhimmel commented 5 years ago

For map_str_edges, I think it will work with edges containing nodes as objects other than strings. Should we make this more clear in its name and docstring. Something like compress_edges_with_int_ids?

https://github.com/hetio/xswap/blob/06cf520b5c54a280bb0446cd104b0d4e052c4544/xswap/preprocessing.py#L41-L110

dhimmel commented 5 years ago

No need to assume this is name right?

name_to_id = {name: i for i, name in enumerate(sorted_node_set)}

Should be node_to_id?

dhimmel commented 5 years ago

For "bipartite" argument docs, can we have the first sentence be:

Use bipartite=True when the edges' source and target nodes are different types. Use bipartite=False when there is no distinction in the type of source and target nodes.

Is that accurate?

dhimmel commented 5 years ago

Regarding:

edges = [('a','b'), ('b','a')]
xswap.preprocessing.map_str_edges(edges, bipartite=True)
([(0, 1), (1, 0)], {'a': 0, 'b': 1}, {'a': 0, 'b': 1})

Is it easy for users to go back to pre-condensed node ids? It seems like the users need the inverted dictionary for {'a': 0, 'b': 1}, {'a': 0, 'b': 1}?

Also we make hetnetpy wrap this package.