code: def is_negatively_weighted(G, edge=None, weight="weight"):
      """Returns True if `G` has negatively weighted edges.
  
      Parameters
      ----------
      G : graph
          A NetworkX graph.
  
      edge : tuple, optional
          A 2-tuple specifying the only edge in `G` that will be tested. If
          None, then every edge in `G` is tested.
  
      weight: string, optional
          The attribute name used to query for edge weights.
  
      Returns
      -------
      bool
          A boolean signifying if `G`, or the specified edge, is negatively
          weighted.
  
      Raises
      ------
      NetworkXError
          If the specified edge does not exist.
  
      Examples
      --------
      >>> G = nx.Graph()
      >>> G.add_edges_from([(1, 3), (2, 4), (2, 6)])
      >>> G.add_edge(1, 2, weight=4)
      >>> nx.is_negatively_weighted(G, (1, 2))
      False
      >>> G[2][4]["weight"] = -2
      >>> nx.is_negatively_weighted(G)
      True
      >>> G = nx.DiGraph()
      >>> edges = [("0", "3", 3), ("0", "1", -5), ("1", "0", -2)]
      >>> G.add_weighted_edges_from(edges)
      >>> nx.is_negatively_weighted(G)
      True
  
      """
      if edge is not None:
          data = G.get_edge_data(*edge)
          if data is None:
              msg = f"Edge {edge!r} does not exist."
              raise nx.NetworkXError(msg)
          return weight in data and data[weight] < 0
  
      return any(
          weight in data and data[weight] < 0
          for u, v, data in G.edges(data=True)
      )
  
imports: from collections import Counter
  from itertools import chain
  import networkx
  from networkx.utils import not_implemented_for, pairwise
label_desc: Use image node_id 32 for calling a global function with example usage: is_negatively_weighted(G, edge, weight) and returns: any, unknown