code: def eccentricity(G, v=None, sp=None, weight=None):
      """Returns the eccentricity of nodes in G.
  
      The eccentricity of a node v is the maximum distance from v to
      all other nodes in G.
  
      Parameters
      ----------
      G : NetworkX graph
         A graph
  
      v : node, optional
         Return value of specified node
  
      sp : dict of dicts, optional
         All pairs shortest path lengths as a dictionary of dictionaries
  
      weight : string, function, or None (default=None)
          If this is a string, then edge weights will be accessed via the
          edge attribute with this key (that is, the weight of the edge
          joining `u` to `v` will be ``G.edges[u, v][weight]``). If no
          such edge attribute exists, the weight of the edge is assumed to
          be one.
  
          If this is a function, the weight of an edge is the value
          returned by the function. The function must accept exactly three
          positional arguments: the two endpoints of an edge and the
          dictionary of edge attributes for that edge. The function must
          return a number.
  
          If this is None, every edge has weight/distance/cost 1.
  
          Weights stored as floating point values can lead to small round-off
          errors in distances. Use integer weights to avoid this.
  
          Weights should be positive, since they are distances.
  
      Returns
      -------
      ecc : dictionary
         A dictionary of eccentricity values keyed by node.
  
      Examples
      --------
      >>> G = nx.Graph([(1, 2), (1, 3), (1, 4), (3, 4), (3, 5), (4, 5)])
      >>> dict(nx.eccentricity(G))
      {1: 2, 2: 3, 3: 2, 4: 2, 5: 3}
  
      >>> dict(nx.eccentricity(G, v=[1, 5]))  # This returns the eccentricity of node 1 & 5
      {1: 2, 5: 3}
  
      """
      #    if v is None:                # none, use entire graph
      #        nodes=G.nodes()
      #    elif v in G:               # is v a single node
      #        nodes=[v]
      #    else:                      # assume v is a container of nodes
      #        nodes=v
      order = G.order()
      e = {}
      for n in G.nbunch_iter(v):
          if sp is None:
              length = nx.shortest_path_length(
                  G, source=n, weight=weight
              )
  
              L = len(length)
          else:
              try:
                  length = sp[n]
                  L = len(length)
              except TypeError as err:
                  raise nx.NetworkXError(
                      'Format of "sp" is invalid.'
                  ) from err
          if L != order:
              if G.is_directed():
                  msg = (
                      "Found infinite path length because the digraph is not"
                      " strongly connected"
                  )
              else:
                  msg = (
                      "Found infinite path length because the graph is not"
                      " connected"
                  )
              raise nx.NetworkXError(msg)
  
          e[n] = max(length.values())
  
      if v in G:
          return e[v]  # return single value
      return e
  
file_path: networkx/networkx/algorithms/distance_measures.py
imports: import networkx
  from networkx.utils import not_implemented_for
label_desc: Use image node_id 2 for calling a global function with example usage: eccentricity(G, v, sp, weight) and returns: e, e