code: def generate_hypergraph(num_nodes, num_edges, r = 0):
      
      # Graph creation
      random_graph = hypergraph()
      
      # Nodes
      nodes = list(map(str, list(range(num_nodes))))
      random_graph.add_nodes(nodes)
      
      # Base edges
      edges = list(map(str, list(range(num_nodes, num_nodes+num_edges))))
      random_graph.add_hyperedges(edges)
      
      # Connect the edges
      if 0 == r:
          # Add each edge with 50/50 probability
          for e in edges:
              for n in nodes:
                  if choice([True, False]):
                      random_graph.link(n, e)
      
      else:
          # Add only uniform edges
          for e in edges:
              # First shuffle the nodes
              shuffle(nodes)
              
              # Then take the first r nodes
              for i in range(r):
                  random_graph.link(nodes[i], e)
      
      return random_graph
docs: Create a random hyper graph.
      
      @type  num_nodes: number
      @param num_nodes: Number of nodes.
      
      @type  num_edges: number
      @param num_edges: Number of edges.
      
      @type  r: number
      @param r: Uniform edges of size r.