class_docstr: A class for utility functions of graph operations.
class_docstr_tok: ["A","class","for","utility","functions","of","graph","operations","."]
docstr: Remove intermediate nodes organized like a line.
docstr_tok: ["Remove","intermediate","nodes","organized","like","a","line","."]
code: def cut_line_node(g):
      """Remove intermediate nodes organized like a line."""
      node_arr = list(g.nodes())
  
      for n in node_arr:
          edge_arr = list(g.edges())
          cnt_in = 0
          cnt_out = 0
          for e in edge_arr:
              if n.id == e[0].id:
                  cnt_out += 1
                  out_ = e[1]
              if n.id == e[1].id:
                  cnt_in += 1
                  in_ = e[0]
          if cnt_in == 1 and cnt_out == 1:
              g.remove_node(n)
              g.add_edge(in_, out_)
      return g
  
file_path: graph4nlp/graph4nlp/pytorch/modules/graph_construction/utility_functions.py
imports: import copy
label_desc: Use image node_id 5 for calling the UtilityFunctionsForGraph obj's underlying member method code with example usage: obj.cut_line_node(g) and returns: g