code: def _theorem5p4(adj, ub):
      
      new_edges = set()
      for u, v in itertools.combinations(adj, 2):
          if u in adj[v]:
              # already an edge
              continue
  
          if len(adj[u].intersection(adj[v])) > ub:
              new_edges.add((u, v))
  
      while new_edges:
          for u, v in new_edges:
              adj[u].add(v)
              adj[v].add(u)
  
          new_edges = set()
          for u, v in itertools.combinations(adj, 2):
              if u in adj[v]:
                  continue
  
              if len(adj[u].intersection(adj[v])) > ub:
                  new_edges.add((u, v))
docs: By Theorem 5.4, if any two vertices have ub + 1 common neighbors
      then we can add an edge between them.