Skip to content

Graphical Coloring of Countries with Condition Satisfaction Algorithm.

Notifications You must be signed in to change notification settings

KeremTAN/ColoringMapAlgorithm-CSP-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ColoringMapAlgorithm-CSP-

Condition Satisfaction Algorithm

Output

UML

Condition

UML

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.

About

Graphical Coloring of Countries with Condition Satisfaction Algorithm.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages