code: def update_potential(leaving_arc_data, pi, cost, spanning_tree):
      thread = spanning_tree.thread
      pred = spanning_tree.pred
      forward = spanning_tree.forward
      last_succ = spanning_tree.last_succ
  
      u_in = leaving_arc_data.u_in
      v_in = leaving_arc_data.v_in
  
      if forward[u_in]:
          sigma = pi[v_in] - pi[u_in] - cost[pred[u_in]]
      else:
          sigma = pi[v_in] - pi[u_in] + cost[pred[u_in]]
  
      # Update potentials in the subtree, which has been moved
      end = thread[last_succ[u_in]]
      u = u_in
      while u != end:
          pi[u] += sigma
          u = thread[u]
  
imports: import numpy
  import numba
  from collections import namedtuple
  from enum import Enum, IntEnum
label_desc: Use image node_id 7 for calling a global function with example usage: update_potential(leaving_arc_data, pi, cost, spanning_tree) without return types