code: def squaring_cycle_graph_old(n, b=10):
      """Return digraph of iterations of powersum(n,2,10)."""
      G = nx.DiGraph()
      for k in range(1, n + 1):
          k1 = k
          G.add_node(k1)  # case k1==knext, at least add node
          knext = powersum(k1, 2, b)
          G.add_edge(k1, knext)
          while k1 != knext:  # stop if fixed point
              k1 = knext
              knext = powersum(k1, 2, b)
              G.add_edge(k1, knext)
              if G.out_degree(knext) >= 1:
                  # knext has already been iterated in and out
                  break
      return G
  
file_path: networkx/examples/algorithms/plot_iterated_dynamical_systems.py
imports: import networkx
label_desc: Use image node_id 4 for calling a global function with example usage: squaring_cycle_graph_old(n, b) and returns: G