{"id":16930349,"url":"https://github.com/erfaniaa/map-coloring","last_synced_at":"2025-10-30T20:18:10.503Z","repository":{"id":40981663,"uuid":"165147070","full_name":"Erfaniaa/map-coloring","owner":"Erfaniaa","description":"Map coloring, using four colors","archived":false,"fork":false,"pushed_at":"2023-12-15T08:28:10.000Z","size":211,"stargazers_count":55,"open_issues_count":4,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T11:02:59.121Z","etag":null,"topics":["backtracking","graph","map-coloring","opencv","planar-graphs","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Erfaniaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-10T23:35:29.000Z","updated_at":"2025-03-02T12:11:32.000Z","dependencies_parsed_at":"2024-10-13T20:41:31.399Z","dependency_job_id":null,"html_url":"https://github.com/Erfaniaa/map-coloring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fmap-coloring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fmap-coloring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fmap-coloring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fmap-coloring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Erfaniaa","download_url":"https://codeload.github.com/Erfaniaa/map-coloring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244951418,"owners_count":20537384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtracking","graph","map-coloring","opencv","planar-graphs","python3"],"created_at":"2024-10-13T20:41:29.519Z","updated_at":"2025-10-30T20:18:05.473Z","avatar_url":"https://github.com/Erfaniaa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# map-coloring\n\n\u003e Map coloring, using four colors\n\nThis program gets a map image as an input and produces all possible valid colorings of that map using backtracking.\n\nThe input image background and borders should be white.\n\n# Some Basic Stuff to Know\n\n1. [Map coloring](https://en.wikipedia.org/wiki/Map_coloring)\n2. [Four color theorem](https://en.wikipedia.org/wiki/Four_color_theorem)\n\n# Algorithm\n\n1. Detecting all non-white regions (eg. provinces or states).\n2. Converting the input map to a simple planar graph:\n   There will be a node for each region. Two nodes will be adjacent, if and only if their corresponding regions have a common border on the map.\n3. Using backtracking for [coloring](https://en.wikipedia.org/wiki/Graph_coloring#Vertex_coloring) that graph (it's a recursive function that produces all valid colorings).\n4. Displaying all produced colorings on the given map.\n\n# Dependencies\n\nInstall numpy, matplotlib and opencv using pip.\n\n```\npip install -r requirements.txt\n```\n\n# Run\n\n```\npython3 map_coloring.py map_image_file_name\n```\n\n# Samples\n\n```\npython3 map_coloring.py iran.jpg\n```\n\nThe original image:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7780269/51145922-88122000-186a-11e9-9577-b4b33f767731.jpg\" width=\"300\"\u003e\n\nA part of the program output:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7780269/51145956-9eb87700-186a-11e9-9eaf-fce66e7b5b6b.gif\" width=\"300\"\u003e\n\n```\npython3 map_coloring.py tehran_province.jpg\n```\n\nThe original image:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7780269/51145925-88122000-186a-11e9-81a5-c3c633496866.jpg\" width=\"300\"\u003e\n\nA part of the program output:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7780269/51145952-9e1fe080-186a-11e9-8968-09861c3a7008.gif\" width=\"300\"\u003e\n\n```\npython3 map_coloring.py usa.png\n```\n\nThe original image:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7780269/51146422-028f6f80-186c-11e9-941c-c77f332c81b4.png\" width=\"300\"\u003e\n\nA part of the program output:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/7780269/51145955-9e1fe080-186a-11e9-9cf2-96fc1a9198f7.gif\" width=\"300\"\u003e\n\n# Notes\n\nIt runs slowly on large images. It can be improved by changing the second part of its algorithm (about setting the graph edges). Some computational geometry knowledge about polygons may be needed for this part.\n\nAny contributions are welcomed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfaniaa%2Fmap-coloring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferfaniaa%2Fmap-coloring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfaniaa%2Fmap-coloring/lists"}