class_docstr: A class to maintain the state during planarity check.
class_docstr_tok: ["A","class","to","maintain","the","state","during","planarity","check","."]
docstr: Orient the graph by DFS, compute lowpoints and nesting order.
docstr_tok: ["Orient","the","graph","by","DFS",",","compute","lowpoints","and","nesting","order","."]
code: def dfs_orientation(self, v):
      """Orient the graph by DFS, compute lowpoints and nesting order."""
      # the recursion stack
      dfs_stack = [v]
      # index of next edge to handle in adjacency list of each node
      ind = defaultdict(lambda: 0)
      # boolean to indicate whether to skip the initial work for an edge
      skip_init = defaultdict(lambda: False)
  
      while dfs_stack:
          v = dfs_stack.pop()
          e = self.parent_edge[v]
  
          for w in self.adjs[v][ind[v] :]:
              vw = (v, w)
  
              if not skip_init[vw]:
                  if (v, w) in self.DG.edges or (w, v) in self.DG.edges:
                      ind[v] += 1
                      continue  # the edge was already oriented
  
                  self.DG.add_edge(v, w)  # orient the edge
  
                  self.lowpt[vw] = self.height[v]
                  self.lowpt2[vw] = self.height[v]
                  if self.height[w] is None:  # (v, w) is a tree edge
                      self.parent_edge[w] = vw
                      self.height[w] = self.height[v] + 1
  
                      dfs_stack.append(v)  # revisit v after finishing w
                      dfs_stack.append(w)  # visit w next
                      skip_init[vw] = True  # don't redo this block
                      break  # handle next node in dfs_stack (i.e. w)
                  else:  # (v, w) is a back edge
                      self.lowpt[vw] = self.height[w]
  
              # determine nesting graph
              self.nesting_depth[vw] = 2 * self.lowpt[vw]
              if self.lowpt2[vw] < self.height[v]:  # chordal
                  self.nesting_depth[vw] += 1
  
              # update lowpoints of parent edge e
              if e is not None:
                  if self.lowpt[vw] < self.lowpt[e]:
                      self.lowpt2[e] = min(
                          self.lowpt[e], self.lowpt2[vw]
                      )
                      self.lowpt[e] = self.lowpt[vw]
                  elif self.lowpt[vw] > self.lowpt[e]:
                      self.lowpt2[e] = min(
                          self.lowpt2[e], self.lowpt[vw]
                      )
                  else:
                      self.lowpt2[e] = min(
                          self.lowpt2[e], self.lowpt2[vw]
                      )
  
              ind[v] += 1
  
imports: from collections import defaultdict
  import networkx
label_desc: Use image node_id 4 for calling the LRPlanarity obj's underlying member method code with example usage: obj.dfs_orientation(v) without return types