Coder Social home page Coder Social logo

map-coloring's Introduction

Linux/Mac/Windows build status

Map Coloring

A demo on using the D-Wave Ocean SDK to solve the map coloring problem. Namely, given a map, color the regions of the map such that no two regions sharing a border would share the same color.

Graph

A graph representation of the provinces of Canada. Provinces connected by edges share a border together. This is a sample output produced by this demo.

Usage

Simply run the code with

python map_coloring.py

Code Overview

The idea is to describe the map coloring problem in terms of constraints. Once this is done, we can use tools from the Ocean SDK to convert these constraints into a binary quadratic model (BQM), a type of equation that can be ingested by the quantum computer. Afterwards, we will hopefully have a solution to our map coloring problem.

Constraints to describe the map coloring problem:

  • Each region can only select one color
  • No regions sharing a border can share a color

Code Specifics

Why only four colors?

  • In the code, we let each of the regions choose one among four colors. Why are we limiting ourselves to only four colors? According to the Four Colour Theorem, we need no more than four colors to color any planar map such that no two adjacent regions share the same color

Alternative implementation

  • To solve the map coloring problem, in this demo, we are forming constraints, converting said constraints into a BQM, and then feeding said BQM to a solver. Please note, however, that the D-Wave Ocean stack also has a function called min_vertex_color_qubo(..) that will directly form the map coloring BQM for you.

License

Released under the Apache License 2.0. See LICENSE file.

map-coloring's People

Contributors

hemantdwave avatar joelpasvolsky avatar m3ller avatar randomir avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.