code: def build_branching(edges, double=False):
      G = nx.DiGraph()
      for u, v, weight in edges:
          G.add_edge(u, v, weight=weight)
          if double:
              G.add_edge(u + 9, v + 9, weight=weight)
      return G
  
imports: import math
  from operator import itemgetter
  import pytest
  import networkx
  from networkx.algorithms.tree import branchings, recognition
label_desc: Use image node_id 3 for calling a global function with example usage: build_branching(edges, double) and returns: G