code: def caveman_graph(l, k):
      """Returns a caveman graph of `l` cliques of size `k`.
  
      Parameters
      ----------
      l : int
        Number of cliques
      k : int
        Size of cliques
  
      Returns
      -------
      G : NetworkX Graph
        caveman graph
  
      Notes
      -----
      This returns an undirected graph, it can be converted to a directed
      graph using :func:`nx.to_directed`, or a multigraph using
      ``nx.MultiGraph(nx.caveman_graph(l, k))``. Only the undirected version is
      described in [1]_ and it is unclear which of the directed
      generalizations is most useful.
  
      Examples
      --------
      >>> G = nx.caveman_graph(3, 3)
  
      See also
      --------
  
      connected_caveman_graph
  
      References
      ----------
      .. [1] Watts, D. J. 'Networks, Dynamics, and the Small-World Phenomenon.'
         Amer. J. Soc. 105, 493-527, 1999.
      """
      # l disjoint cliques of size k
      G = nx.empty_graph(l * k)
      if k > 1:
          for start in range(0, l * k, k):
              edges = itertools.combinations(range(start, start + k), 2)
              G.add_edges_from(edges)
      return G
  
file_path: networkx/networkx/generators/community.py
imports: import itertools
  import math
  import networkx
  from networkx.utils import py_random_state
label_desc: Use image node_id 1 for calling a global function with example usage: caveman_graph(l, k) and returns: G