File:Collatz-graph-300.svg

Summary

Description
English: Directed graph showing the orbits of all the odd numbers less than 300 under the Collatz map.
Date
Source Own work
Author Keenan Pepper
SVG development
InfoField
 The SVG code is valid.
 This chart was created with Graphviz.
Category:Valid SVG created with Graphviz#Collatz-graph-300.svg
 Category:Translation possible - SVGThis file uses embedded text that can be easily translated using a text editor.

Source code

 dotfile = file('collatz-graph.dot', 'w')
 
 limit = 300
 
 def f(n):
   while n % 2 == 0: # divide by 2 until it's odd
     n /= 2
   n = 3*n + 1
   while n % 2 == 0:
     n /= 2
   return n
 
 explored = set([1])
 
 dotfile.write('digraph {\n')
 
 for n in range(3, limit, 2): # odd numbers
   while n not in explored:
     dotfile.write(str(n) + ' -> ')
     explored.add(n)
     n = f(n)
   dotfile.write(str(n) + ';\n')
 
 dotfile.write('}\n')

Licensing

Public domain This work has been released into the public domain by its author, Keenan Pepper. This applies worldwide.
In some countries this may not be legally possible; if so:
Keenan Pepper grants anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
Category:Self-published work#Collatz-graph-300.svgCategory:PD-self#Collatz-graph-300.svg Category:Collatz conjecture
Category:Collatz conjecture Category:PD-self Category:Self-published work Category:Translation possible - SVG Category:Valid SVG created with Graphviz