code: def random_geometric_graph(
      n, radius, dim=2, pos=None, p=2, seed=None, *, pos_name="pos"
  ):
      """Returns a random geometric graph in the unit cube of dimensions `dim`.
  
      The random geometric graph model places `n` nodes uniformly at
      random in the unit cube. Two nodes are joined by an edge if the
      distance between the nodes is at most `radius`.
  
      Edges are determined using a KDTree when SciPy is available.
      This reduces the time complexity from $O(n^2)$ to $O(n)$.
  
      Parameters
      ----------
      n : int or iterable
          Number of nodes or iterable of nodes
      radius: float
          Distance threshold value
      dim : int, optional
          Dimension of graph
      pos : dict, optional
          A dictionary keyed by node with node positions as values.
      p : float, optional
          Which Minkowski distance metric to use.  `p` has to meet the condition
          ``1 <= p <= infinity``.
  
          If this argument is not specified, the :math:`L^2` metric
          (the Euclidean distance metric), p = 2 is used.
          This should not be confused with the `p` of an Erdős-Rényi random
          graph, which represents probability.
      seed : integer, random_state, or None (default)
          Indicator of random number generation state.
          See :ref:`Randomness<randomness>`.
      pos_name : string, default="pos"
          The name of the node attribute which represents the position
          in 2D coordinates of the node in the returned graph.
  
      Returns
      -------
      Graph
          A random geometric graph, undirected and without self-loops.
          Each node has a node attribute ``'pos'`` that stores the
          position of that node in Euclidean space as provided by the
          ``pos`` keyword argument or, if ``pos`` was not provided, as
          generated by this function.
  
      Examples
      --------
      Create a random geometric graph on twenty nodes where nodes are joined by
      an edge if their distance is at most 0.1::
  
      >>> G = nx.random_geometric_graph(20, 0.1)
  
      Notes
      -----
      This uses a *k*-d tree to build the graph.
  
      The `pos` keyword argument can be used to specify node positions so you
      can create an arbitrary distribution and domain for positions.
  
      For example, to use a 2D Gaussian distribution of node positions with mean
      (0, 0) and standard deviation 2::
  
      >>> import random
      >>> n = 20
      >>> pos = {i: (random.gauss(0, 2), random.gauss(0, 2)) for i in range(n)}
      >>> G = nx.random_geometric_graph(n, 0.2, pos=pos)
  
      References
      ----------
      .. [1] Penrose, Mathew, *Random Geometric Graphs*,
             Oxford Studies in Probability, 5, 2003.
  
      """
      # TODO Is this function just a special case of the geographical
      # threshold graph?
      #
      #     half_radius = {v: radius / 2 for v in n}
      #     return geographical_threshold_graph(nodes, theta=1, alpha=1,
      #                                         weight=half_radius)
      #
      G = nx.empty_graph(n)
      # If no positions are provided, choose uniformly random vectors in
      # Euclidean space of the specified dimension.
      if pos is None:
          pos = {v: [seed.random() for i in range(dim)] for v in G}
      nx.set_node_attributes(G, pos, pos_name)
  
      G.add_edges_from(_geometric_edges(G, radius, p, pos_name))
      return G
  
file_path: networkx/networkx/generators/geometric.py
imports: import math
  from bisect import bisect_left
  from itertools import accumulate, combinations, product
  import networkx
  from networkx.utils import py_random_state
label_desc: Use image node_id 3 for calling a global function with example usage: random_geometric_graph(n, radius, dim, pos, p, seed) and returns: G