Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaiswalchitransh/csp-map-coloring-using-backtracking
The code uses backtracking to solve the Constraint Satisfaction Problem (CSP) of map coloring. It checks if assigning colors to regions follows the constraint that no adjacent regions have the same color. The skills involved include algorithm design for backtracking, recursion, and solving CSP problems. The implementation uses Python.
https://github.com/jaiswalchitransh/csp-map-coloring-using-backtracking
ai artificial-intelligence backtracking csp map-coloring project python python-3 python3 recursion
Last synced: 24 days ago
JSON representation
The code uses backtracking to solve the Constraint Satisfaction Problem (CSP) of map coloring. It checks if assigning colors to regions follows the constraint that no adjacent regions have the same color. The skills involved include algorithm design for backtracking, recursion, and solving CSP problems. The implementation uses Python.
- Host: GitHub
- URL: https://github.com/jaiswalchitransh/csp-map-coloring-using-backtracking
- Owner: jaiswalchitransh
- Created: 2024-02-01T19:24:27.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-08-28T20:40:01.000Z (5 months ago)
- Last Synced: 2024-11-05T22:42:27.810Z (2 months ago)
- Topics: ai, artificial-intelligence, backtracking, csp, map-coloring, project, python, python-3, python3, recursion
- Language: Python
- Homepage:
- Size: 344 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CSP Map coloring using Backtracking
## Table of Contents
- [Project Overview](#project-overview)
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [Contribution](#contribution)## Project Overview
The Python code tackles the map coloring problem, a classic graph theory challenge where the objective is to color the regions of a map in such a way that no two adjacent regions share the same color. The code employs a backtracking algorithm, which systematically explores different color assignments until a valid solution is discovered or all possibilities have been exhausted.## Installation
This project requires Python 3.12.1 or later.
To set up the project:
1. Ensure Python 3.12.1 or a later version is installed on your system. You can download Python from [python.org](https://www.python.org/downloads/).
2. Clone or download the repository to your local machine.git clone https://github.com/jaiswalchitransh/CSP-Map-coloring-using-Backtracking.git
3. Open the project in your preferred Python environment (e.g., IDE or terminal).
4. Modify the `map`, `regions`, and `colors` variables in the main block of the `map_coloring.py` script according to your map and color choices.
5. Run the script (`csp_map_coloring.py`) and observe the output to see the valid coloring of regions.## Usage
Modify the `map`, `regions`, and `colors` variables in the main block according to your map and color choices.Run the script:
python csp_map_coloring.py
Observe the output to see the valid coloring of regions.## Features
- **Backtracking Algorithm**: Utilizes a backtracking approach to systematically explore and find valid colorings for the map.
- **is_valid Function**: Checks whether a color assignment for a region is valid based on its neighbors.
- **solve_map_coloring Function**: Recursively attempts to find a valid coloring for the entire map.
- **Main Block**: Provides a sample map with regions and their neighbors, along with a list of available colors, demonstrating how the solver works.## Contribution
I, **[Chitransh Jaiswal](https://www.linkedin.com/in/jaiswalchitransh/)** developed this Project Individually. I was responsible for all aspects of the project, including design, development, testing, and documentation.
Contributions to improve the efficiency, readability, or functionality of the code are welcome. To contribute:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature/your-feature`).
3. Make your changes.
4. Commit your changes (`git commit -am 'Add some feature'`).
5. Push to the branch (`git push origin feature/your-feature`).
6. Create a new Pull Request.Please ensure your contributions adhere to the coding standards and follow the existing style and structure.
---
Thank you for your interest in the CSP Map Coloring using Backtracking!