Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keremtan/coloringmapalgorithm-csp-
Graphical Coloring of Countries with Condition Satisfaction Algorithm.
https://github.com/keremtan/coloringmapalgorithm-csp-
algorithm coloring-algorithm coloring-graph computer-algorithm csp
Last synced: 4 days ago
JSON representation
Graphical Coloring of Countries with Condition Satisfaction Algorithm.
- Host: GitHub
- URL: https://github.com/keremtan/coloringmapalgorithm-csp-
- Owner: KeremTAN
- Created: 2022-01-05T10:49:02.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-08T14:57:34.000Z (almost 3 years ago)
- Last Synced: 2024-01-27T06:39:54.270Z (11 months ago)
- Topics: algorithm, coloring-algorithm, coloring-graph, computer-algorithm, csp
- Language: Python
- Homepage:
- Size: 113 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ColoringMapAlgorithm-CSP-
## Condition Satisfaction Algorithm
### Output
![UML](https://github.com/KeremTAN/ColoringMapAlgorithm-CSP-/blob/master/img/countries.png)
### Condition
![UML](https://github.com/KeremTAN/ColoringMapAlgorithm-CSP-/blob/master/img/condition.png)Our 1st method has 2 parameters and does the sorting of the countries.
In its parameter, it takes the graph structure of the countries and the list of names of the unsorted countries.
Note: the graph structure of countries is defined as a local variable dictionary.
It is important that we sort our countries from the most to the least number of neighbors, because if we don't do this and
color the countries with the fewest neighbors first, the colors of the countries with
the fewest neighbors will coincide with those of the neighboring countries.
Our method returns the sorted countries after sorting.
Our 2nd method has 2 parameters and checks for correct coloring of country colors.
In its parameter, it takes the graph structure of the countries and the color dictionary of the countries.
First of all, it checks the countries that are on our graph and have not yet been added to our dictionary.
Then, we compare the colors of the countries and their neighbors in our dictionary through our graph.
If a country and any of its neighbors have the same color, we return the wrong value.
Our 3rd method has 3 parameters and does the coloring of the countries.
In its parameter, it takes the graph structure of the countries, an empty dictionary for us to color, and an unsorted list of countries' names.
This method first calls our 1st method and sorts our unordered countries.
Our method traverses the sorted lists of countries and colors with indices to color our countries.
After coloring a country, it performs control with our 2nd method.
If it returns a false value to us, it colors the same country again, reducing the index it uses to hover by 1.
It also increments our solver-counter by 1.
When the number of elements of our solver-counter and our colors list are equal, it gives the message "unsolved problem".
After that, our method returns a false value with an empty dictionary and ends our program.
If our 2nd method returns true, it resets our solver-counter and continues coloring the countries.
After all countries are colored, our method returns two values. One is the colored dictionary of countries and the other is the correct value.