code: def cost_of_flow(G, flowDict, weight="weight"):
      """Compute the cost of the flow given by flowDict on graph G.
  
      Note that this function does not check for the validity of the
      flow flowDict. This function will fail if the graph G and the
      flow don't have the same edge set.
  
      Parameters
      ----------
      G : NetworkX graph
          DiGraph on which a minimum cost flow satisfying all demands is
          to be found.
  
      weight : string
          Edges of the graph G are expected to have an attribute weight
          that indicates the cost incurred by sending one unit of flow on
          that edge. If not present, the weight is considered to be 0.
          Default value: 'weight'.
  
      flowDict : dictionary
          Dictionary of dictionaries keyed by nodes such that
          flowDict[u][v] is the flow edge (u, v).
  
      Returns
      -------
      cost : Integer, float
          The total cost of the flow. This is given by the sum over all
          edges of the product of the edge's flow and the edge's weight.
  
      See also
      --------
      max_flow_min_cost, min_cost_flow, min_cost_flow_cost, network_simplex
  
      Notes
      -----
      This algorithm is not guaranteed to work if edge weights or demands
      are floating point numbers (overflows and roundoff errors can
      cause problems). As a workaround you can use integer numbers by
      multiplying the relevant edge attributes by a convenient
      constant factor (eg 100).
  
      Examples
      --------
      >>> G = nx.DiGraph()
      >>> G.add_node("a", demand=-5)
      >>> G.add_node("d", demand=5)
      >>> G.add_edge("a", "b", weight=3, capacity=4)
      >>> G.add_edge("a", "c", weight=6, capacity=10)
      >>> G.add_edge("b", "d", weight=1, capacity=9)
      >>> G.add_edge("c", "d", weight=2, capacity=5)
      >>> flowDict = nx.min_cost_flow(G)
      >>> flowDict
      {'a': {'b': 4, 'c': 1}, 'd': {}, 'b': {'d': 4}, 'c': {'d': 1}}
      >>> nx.cost_of_flow(G, flowDict)
      24
      """
      return sum(
          (
              flowDict[u][v] * d.get(weight, 0)
              for u, v, d in G.edges(data=True)
          )
      )
  
imports: import networkx
label_desc: Use image node_id 3 for calling a global function with example usage: cost_of_flow(G, flowDict, weight) and returns: sum