Skip to content

Instantly share code, notes, and snippets.

@xalelax
Last active January 2, 2021 17:08
Show Gist options
  • Select an option

  • Save xalelax/c9755404b1067cd0bd947dffd47ec536 to your computer and use it in GitHub Desktop.

Select an option

Save xalelax/c9755404b1067cd0bd947dffd47ec536 to your computer and use it in GitHub Desktop.
from collections import defaultdict
def decompose_edges_by_len(hypergraph):
decomposed_edges = defaultdict(list)
for edge in hypergraph['edges']:
decomposed_edges[len(edge)].append(edge)
decomposition = {
'nodes': hypergraph['nodes'],
'edges': decomposed_edges
}
return decomposition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment