code: def find_leaving_arc(join, in_arc, node_arc_data, spanning_tree):
      source = node_arc_data.source
      target = node_arc_data.target
      flow = node_arc_data.flow
  
      state = spanning_tree.state
      forward = spanning_tree.forward
      pred = spanning_tree.pred
      parent = spanning_tree.parent
  
      u_out = -1  # May not be set, but we need to return something?
  
      # Initialize first and second nodes according to the direction
      # of the cycle
      if state[in_arc] == ArcState.STATE_LOWER:
          first = source[in_arc]
          second = target[in_arc]
      else:
          first = target[in_arc]
          second = source[in_arc]
  
      delta = INFINITY
      result = 0
  
      # Search the cycle along the path form the first node to the root
      u = first
      while u != join:
          e = pred[u]
          if forward[u]:
              d = flow[e]
          else:
              d = INFINITY
  
          if d < delta:
              delta = d
              u_out = u
              result = 1
  
          u = parent[u]
  
      # Search the cycle along the path form the second node to the root
      u = second
      while u != join:
          e = pred[u]
          if forward[u]:
              d = INFINITY
          else:
              d = flow[e]
  
          if d <= delta:
              delta = d
              u_out = u
              result = 2
  
          u = parent[u]
  
      if result == 1:
          u_in = first
          v_in = second
      else:
          u_in = second
          v_in = first
  
      return LeavingArcData(u_in, u_out, v_in, delta, result != 0)
  
imports: import numpy
  import numba
  from collections import namedtuple
  from enum import Enum, IntEnum
label_desc: Use image node_id 4 for calling a global function with example usage: find_leaving_arc(join, in_arc, node_arc_data, spanning_tree) and returns: LeavingArcData