docs: def network_simplex(self, display, pivot, root):
          '''
          API:
              network_simplex(self, display, pivot, root)
          Description:
              Solves minimum cost feasible flow problem using network simplex
              algorithm. It is recommended to use min_cost_flow(algo='simplex')
              instead of using network_simplex() directly. Returns True when an
              optimal solution is found, returns False otherwise. 'flow' attribute
              values of arcs should be considered as junk when returned False.
          Pre:
              (1) check Pre section of min_cost_flow()
          Input:
              pivot: specifies pivot rule. Check min_cost_flow()
              display: 'off' for no display, 'pygame' for live update of
              spanning tree.
              root: Root node for the underlying spanning trees that will be
              generated by network simplex algorthm.
          Post:
              (1) Changes 'flow' attribute of edges.
          Return:
              Returns True when an optimal solution is found, returns
              False otherwise.
          '''
          # ==== determine an initial tree structure (T,L,U)
          # find a feasible flow
          if not self.find_feasible_flow():
              return False
          t = self.simplex_find_tree()
          self.set_display_mode(display)
          # mark spanning tree arcs
          self.simplex_mark_st_arcs(t)
          # display initial spanning tree
          t.simplex_redraw(display, root)
          t.set_display_mode(display)
          #t.display()
          self.display()
          # set predecessor, depth and thread indexes
          t.simplex_search(root, 1)
          # compute potentials
          self.simplex_compute_potentials(t, root)
          # while some nontree arc violates optimality conditions
          while not self.simplex_optimal(t):
              self.display()
              # select an entering arc (k,l)
              (k,l) = self.simplex_select_entering_arc(t, pivot)
              self.simplex_mark_entering_arc(k, l)
              self.display()
              # determine leaving arc
              ((p,q), capacity, cycle)=self.simplex_determine_leaving_arc(t,k,l)
              # mark leaving arc
              self.simplex_mark_leaving_arc(p, q)
              self.display()
              self.simplex_remove_arc(t, p, q, capacity, cycle)
              # display after arc removed
              self.display()
              self.simplex_mark_st_arcs(t)
              self.display()
              # set predecessor, depth and thread indexes
              t.simplex_redraw(display, root)
              #t.display()
              t.simplex_search(root, 1)
              # compute potentials
              self.simplex_compute_potentials(t, root)
          return True