def squaring_cycle_graph_old(n, b=10):
 G = DiGraph()
 for k in range(1, (n + 1)):
  k1 = k
  G.add_node(k1)
  knext = powersum(k1, 2, b)
  G.add_edge(k1, knext)
  while (k1 != knext):
   k1 = knext
   knext = powersum(k1, 2, b)
   G.add_edge(k1, knext)
   if (G.out_degree(knext) >= 1):
    break
 return G

def squaring_cycle_graph_old ( n , b = 10 ) : G = DiGraph ( ) for k in range ( 1 , ( n + 1 ) ) : k1 = k G . add_node ( k1 ) knext = powersum ( k1 , 2 , b ) G . add_edge ( k1 , knext ) while ( k1 != knext ) : k1 = knext knext = powersum ( k1 , 2 , b ) G . add_edge ( k1 , knext ) if ( G . out_degree ( knext ) >= 1 ) : break return G
return digraph of iterations of powersum .