Skip to content

Repository files navigation

Reverse Collatz Conjecture Mind Map

This project explores the Collatz conjecture by working backward from the number 1. It generates a tree-like "mind map" of all the numbers that lead to 1, revealing the branching structure of the reversed sequences.

Project Overview

The standard Collatz conjecture starts with a positive integer n and repeatedly applies two rules:

  • If n is even, the next term is n / 2.
  • If n is odd, the next term is 3n + 1.

This project does the reverse:

  • If a number m is even, its predecessor could be m / 2 (since (m/2) * 2 = m).
  • If a number m can be expressed as 3n + 1, its predecessor could be n = (m - 1) / 3.

By starting at 1 and applying these reverse rules, we can generate a tree of all numbers that eventually lead to 1.

File Descriptions

  • collatz_mindmap.py: This is the primary data generation script. It builds the reverse Collatz tree starting from 1 up to a specified depth. It produces a JSON file that represents this tree structure.

  • visualize_mindmap.py: This script takes the JSON data generated by the first script and uses the Graphviz library to create a visually appealing PNG image of the mind map.

  • main.py: The original script for analyzing Collatz sequences, likely used to generate the initial data in the advanced_analysis and graphs directories.

  • collatz_mindmap.json: An intermediate data file containing the mind map structure in a hierarchical format. This file is read by visualize_mindmap.py.

  • graphs/collatz_mindmap_visualization.png: The final output image of the mind map.

Prerequisites

Before running the scripts, you need to have the following installed:

  1. Python 3: Download Python

  2. Graphviz Software: This is a separate program required for rendering the graph.

    • Download: https://graphviz.org/download/
    • Important: During installation, ensure you add Graphviz to your system's PATH environment variable. The installer usually provides a checkbox for this.
  3. Python graphviz Library: Install this using pip after installing the Graphviz software.

    pip install graphviz

How to Use

Follow these steps to generate and view the mind map:

Step 1: Generate the Mind Map Data

Run the collatz_mindmap.py script. This will create the collatz_mindmap.json file.

python collatz_mindmap.py

Step 2: Create the Visualization

Next, run the visualize_mindmap.py script. This reads the JSON file and creates the PNG image.

python visualize_mindmap.py

The final image will be saved as graphs/collatz_mindmap_visualization.png.

Customizing the Mind Map

To generate a larger or smaller mind map, you can change the search depth.

  1. Open the collatz_mindmap.py file in a text editor.
  2. Find the line MAX_DEPTH = 8 near the end of the file.
  3. Change the number 8 to a higher value (e.g., 10, 12) for a larger tree, or a lower value for a smaller one.
  4. Save the file.
  5. Re-run both scripts as described in the "How to Use" section to see your changes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages