Skip to content

Instantly share code, notes, and snippets.

@xalelax
Last active January 3, 2021 14:27
Show Gist options
  • Select an option

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

Select an option

Save xalelax/5e76c9e01522499797fa0f9dc3590d44 to your computer and use it in GitHub Desktop.
import random
def generate_random_hypergraph(order, size):
nodes = set(range(order))
edges = set()
while len(edges) < size:
edge_size = random.randint(2, order)
edge = frozenset(random.sample(nodes, k=edge_size))
if edge not in edges:
edges.add(edge)
return {'nodes': nodes, 'edges': edges}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment