code: def k_core(G, k=None, core_number=None):
      """Returns the k-core of G.
  
      A k-core is a maximal subgraph that contains nodes of degree `k` or more.
  
      .. deprecated:: 3.3
         `k_core` will not accept `MultiGraph` objects in version 3.5.
  
      Parameters
      ----------
      G : NetworkX graph
        A graph or directed graph
      k : int, optional
        The order of the core. If not specified return the main core.
      core_number : dictionary, optional
        Precomputed core numbers for the graph G.
  
      Returns
      -------
      G : NetworkX graph
        The k-core subgraph
  
      Raises
      ------
      NetworkXNotImplemented
        The k-core is not defined for multigraphs or graphs with self loops.
  
      Notes
      -----
      The main core is the core with `k` as the largest core_number.
  
      For directed graphs the node degree is defined to be the
      in-degree + out-degree.
  
      Graph, node, and edge attributes are copied to the subgraph.
  
      Examples
      --------
      >>> degrees = [0, 1, 2, 2, 2, 2, 3]
      >>> H = nx.havel_hakimi_graph(degrees)
      >>> H.degree
      DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
      >>> nx.k_core(H).nodes
      NodeView((1, 2, 3, 5))
  
      See Also
      --------
      core_number
  
      References
      ----------
      .. [1] An O(m) Algorithm for Cores Decomposition of Networks
         Vladimir Batagelj and Matjaz Zaversnik,  2003.
         https://arxiv.org/abs/cs.DS/0310049
      """
  
      import warnings
  
      if G.is_multigraph():
          warnings.warn(
              (
                  "\n\n`k_core` will not accept `MultiGraph` objects in version 3.5.\n"
                  "Convert it to an undirected graph instead, using::\n\n"
                  "\tG = nx.Graph(G)\n"
              ),
              category=DeprecationWarning,
              stacklevel=5,
          )
  
      def k_filter(v, k, c):
          return c[v] >= k
  
      return _core_subgraph(G, k_filter, k, core_number)
  
file_path: networkx/networkx/algorithms/core.py
imports: import networkx
label_desc: Use image node_id 3 for calling a global function with example usage: k_core(G, k, core_number) and returns: _core_subgraph, unknown