Skip to content

Annealing and Ising

minorminer

Maintained by dwavesystems

minorminer is a heuristic tool for minor embedding: given a minor and target graph, it tries to find a mapping that embeds the minor into the target.

PythonApache-2.0
minorminer illustration

Resource snapshot

Category

Annealing and Ising

Stars

53

Last pushed

Jan 27, 2026Updated 7mo ago

Open issues

30

What it is

minorminer is maintained by dwavesystems and sits in the Annealing and Ising lane of the open-source quantum map.

minorminer is a heuristic tool for minor embedding: given a minor and target graph, it tries to find a mapping that embeds the minor into the target. It commonly appears alongside dwavesystems-dimod, dwavesystems-dwave-ocean-sdk in example workflows.

Last verified by Qtangl generator on May 27, 2026

Who it's for

Developers interested in Ising-model formulations, annealing workflows, and D-Wave-style solver ecosystems.

What you can build or learn

  • See how annealing-oriented projects model optimization problems.
  • Understand embeddings, samplers, and the surrounding tooling needed in practice.
  • Compare annealing workflows against gate-model and hybrid alternatives.

Code samples

Examples from the repository.

Algorithm Demo (examples/algorithm_demo.py)
"""
This file shows a visualization of the minorminer.find_embedding() algorithm.
At each step of the find_embedding() algorithm, a new chain is inserted for a node in the source graph, where chains
are allowed to overlap. After all chains have inserted, the algorithm iteratively removes and reinserts chains,
attempting to minimize the amount of overlap between them. Eventually all overlap will be removed, and the result is
a valid embedding.
In this example, a complete graph K_8 is embedded into a chimera_graph C_2.
"""
from minorminer import miner
import networkx as nx
import dwave_networkx as dnx
import matplotlib.pyplot as plt
# Parameters of the demo
wait_for_input = False                   # wait for user input to advance to the next step
G = nx.complete_graph(8)                # source graph
C = dnx.generators.chimera_graph(2)     # target graph
def show_current_embedding(emb):
    # visualize overlaps.
    plt.clf()
    dnx.draw_chimera_embedding(C, emb=emb, overlapped_embedding=True, show_labels=True)
    plt.show()
    if wait_for_input:
        plt.pause(0.001)
        input()
    else:
        plt.pause(1)
def compute_bags(C, emb):
    # Given an overlapped embedding, compute the set of source nodes embedded at every target node.
    bags = {v: [] for v in C.nodes()}
    for x, chain in emb.items():
        for v in chain:
            bags[v].append(x)
    return bags
# Run the algorithm.
plt.ion()
m = miner(G, C, random_seed=0)
found = False
emb = {}
print("Embedding K_8 into Chimera C(2).")
for iteration in range(3):
Parallel Embeddings Demo (examples/parallel_embeddings_demo.py)
"""
This demo illustrates the process of checking graph embedding feasibility and performing raster embeddings
across various D-Wave graph topologies such as Chimera, Pegasus, and Zephyr.
The demo performs the following steps:
1. **Embedding Feasibility Checks**:
    - For each source topology, it generates a subgraph and checks whether it can be embedded into each target topology.
    - It reports whether the embedding is feasible and, if so, the required sublattice size.
2. **Raster Embedding Examples**:
    - For each topology, it performs raster embeddings at the minimal scale.
    - It visualizes the embeddings if visualization is enabled.
    - It validates the embeddings and displays the results.
This example demonstrates how to assess and visualize graph embeddings using D-Wave's `dwave_networkx` library.
"""
import dwave_networkx as dnx
from minorminer.utils.parallel_embeddings import (
    find_sublattice_embeddings,
    embeddings_to_array,
)
from minorminer.utils.feasibility import (
    lattice_size_lower_bound,
)
def main():
    print("Minimum Subgraph Embedding (graph rows) Examples\n")
    # Parameters
    visualize = True  # Enable or disable visualization
    topologies = ["chimera", "pegasus", "zephyr"]  # Target graph topologies
    smallest_tile = {
        "chimera": 1,
        "pegasus": 2,
        "zephyr": 1,
    }  # Minimum tile sizes for each topology
    generators = {
        "chimera": dnx.chimera_graph,
        "pegasus": dnx.pegasus_graph,
        "zephyr": dnx.zephyr_graph,
    }
    # Iterate over each source topology for embedding feasibility checks
    for source_topology in topologies:
        sublattice_size_S = smallest_tile[source_topology] + 1
        S = generators[source_topology](sublattice_size_S)
Suspend Chains (examples/suspend_chains.py)
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
import minorminer
import networkx as nx
import dwave_networkx as dnx
import matplotlib.pyplot as plt
K3 = nx.Graph([('A', 'B'), ('B', 'C'), ('C', 'A')])
plt.subplot(2, 2, 1)
nx.draw(K3, with_labels=True)
C = dnx.chimera_graph(1, 2, coordinates=False)
plt.subplot(2, 2, 2)
dnx.draw_chimera(C, with_labels=True)
# Example with one blob for one node. Source node will use at least one.
blob = [4, 5, 12, 13]
suspend_chains = {'A': [blob]}
embedding = minorminer.find_embedding(K3, C, suspend_chains=suspend_chains)
plt.subplot(2, 2, 3)
dnx.draw_chimera_embedding(C, embedding, with_labels=True)
# Example with one blob for one node, and two blobs for another.
# Second source node is forced to use at least one in each blob.
blob_A0 = [4, 5]
blob_A1 = [12, 13]
blob_C0 = [6, 7, 14, 15]
suspend_chains = {'A': [blob_A0, blob_A1], 'C': [blob_C0]}
embedding = minorminer.find_embedding(K3, C, suspend_chains=suspend_chains)
plt.subplot(2, 2, 4)
dnx.draw_chimera_embedding(C, embedding, show_labels=True)

Plays well with

License

Apache-2.0

SPDX identifier detected from the repository metadata or license files.

Repository README

Preview from the project README.

Rendered as Markdown inside a scrollable preview. Long READMEs stay contained; expand or open on GitHub for the full document.

~827 words · about 4 min readOpen on GitHub

:target: https://pypi.org/project/minorminer

:target: https://pypi.python.org/pypi/minorminer

.. image:: https://circleci.com/gh/dwavesystems/minorminer.svg?style=svg :target: https://circleci.com/gh/dwavesystems/minorminer

:target: https://arxiv.org/abs/1406.2741

:target: https://arxiv.org/abs/1507.04774

========== minorminer

.. start_minorminer_about

minorminer is a heuristic tool for minor embedding: given a minor and target graph, it tries to find a mapping that embeds the minor into the target.

.. start_minorminer_about_general_embedding

The primary utility function, find_embedding(), is an implementation of the heuristic algorithm described in [1]. It accepts various optional parameters used to tune the algorithm's execution or constrain the given problem.

This implementation performs on par with tuned, non-configurable implementations while providing users with hooks to easily use the code as a basic building block in research.

[1] https://arxiv.org/abs/1406.2741

Another function, find_clique_embedding(), can be used to find clique embeddings for Chimera, Pegasus, and Zephyr graphs in polynomial time. It is an implementation of the algorithm described in [2]. There are additional utilities for finding biclique embeddings as well.

[2] https://arxiv.org/abs/1507.04774

.. end_minorminer_about

Python

Installation

pip installation is recommended for platforms with precompiled wheels posted to pypi. Source distributions are provided as well.

.. code-block:: bash

pip install minorminer

To install from this repository, you will need to first fetch the submodules

.. code-block:: bash

git submodule init
git submodule update

and then run the setuptools script.

.. code-block:: bash

pip install -r requirements.txt
python setup.py install
# optionally, run the tests to check your build
pip install -r tests/requirements.txt
python -m pytest .

Examples

.. start_minorminer_examples_python

.. code-block:: python

from minorminer import find_embedding

# A triangle is a minor of a square.
triangle = [(0, 1), (1, 2), (2, 0)]
square = [(0, 1), (1, 2), (2, 3), (3, 0)]

# Find an assignment of sets of square variables to the triangle variables
embedding = find_embedding(triangle, square, random_seed=10)
print(len(embedding))  # 3, one set for each variable in the triangle
print(embedding)
# We don't know which variables will be assigned where, here are a
# couple possible outputs:
# [[0, 1], [2], [3]]
# [[3], [1, 0], [2]]

.. code-block:: python

# We can insist that variable 0 of the triangle will always be assigned to [2]
embedding = find_embedding(triangle, square, fixed_chains={0: [2]})
print(embedding)
# [[2], [3, 0], [1]]
# [[2], [1], [0, 3]]
# And more, but all of them start with [2]

.. code-block:: python

# If we didn't want to force variable 0 to stay as [2], but we thought that
# was a good start we could provide it as an initialization hint instead.
embedding = find_embedding(triangle, square, initial_chains={0: [2]})
print(embedding)
# [[2], [0, 3], [1]]
# [[0], [3], [1, 2]]
# Output where variable 0 has switched to something else is possible again.

.. code-block:: python

import networkx as nx

# An example on some less trivial graphs
# We will try to embed a fully connected graph with 6 nodes, into a
# random regular graph with degree 3.
clique = nx.complete_graph(6).edges()
target_graph = nx.random_regular_graph(d=3, n=30).edges()

embedding = find_embedding(clique, target_graph)

print(embedding)
# There are many possible outputs for this, sometimes it might even fail
# and return an empty list

A more fleshed out example can be found under examples/fourcolor.py

.. code-block:: bash

cd examples
pip install -r requirements.txt
python fourcolor.py

.. end_minorminer_examples_python

C++

Installation

The CMakeLists.txt in the root of this repo will build the library and optionally run a series of tests. On Linux, the commands would be something like this:

.. code-block:: bash

mkdir build; cd build
cmake ..
make

To build the tests, turn the CMake option MINORMINER_BUILD_TESTS on. The command line option for CMake to do this would be -DMINORMINER_BUILD_TESTS=ON.

Library Usage

C++11 programs should be able to use this as a header-only library. If your project is using CMake, this library can be used fairly simply; if you have checked out this repo as externals/minorminer in your project, you would need to add the following lines to your CMakeLists.txt

.. code-block:: CMake

add_subdirectory(externals/minorminer)

# After your target is defined
target_link_libraries(your_target minorminer pthread)

Examples

A minimal buildable example can be found in this repo under examples/example.cpp.

.. code-block:: bash

cd examples
g++ example.cpp -std=c++11 -o example -pthread

This can also be built using the included CMakeLists.txt along with the main library build by turning the CMake option MINORMINER_BUILD_EXAMPLES on. The command line option for CMake to do this would be -DMINORMINER_BUILD_EXAMPLES=ON.

License

Released under the Apache License 2.0. See <LICENSE>_ file.

Contributing

Ocean's contributing guide <https://docs.dwavequantum.com/en/latest/ocean/contribute.html>_ has guidelines for contributing to Ocean packages.

If you're interested in adding or modifying parameters of the find_embedding primary utility function, please see the <parameter_checklist.txt>_ file.

Release Notes

minorminer makes use of reno <https://docs.openstack.org/reno/>_ to manage its release notes.

When making a contribution to minorminer that will affect users, create a new release note file by running

.. code-block:: bash

reno new your-short-descriptor-here

You can then edit the file created under releasenotes/notes/. Remove any sections not relevant to your changes. Commit the file along with your changes.

See reno's user guide <https://docs.openstack.org/reno/latest/user/usage.html>_ for details.

Read on GitHub

Activity

Latest release

—

Watchers

14

Python support

>= 3.10

Key dependencies

dwave-networkx, fasteners, homebase, networkx, numpy, scipy

Learn digest

Get monthly updates when library entries change.

Monthly digest: new library entries, updated flagships, and one editorial pick.

Related resources

Keep exploring nearby tools.

dwavesystems

chimera-embedding

This is a repository for algorithms to generate native-structured embeddings.

PythonApache-2.0

28 stars · Updated 7y ago

dwavesystems

dimod

A shared API for QUBO/Ising samplers.

PythonApache-2.0FlagshipQtangl relevant

142 stars · Updated 3mo ago

dwavesystems

dwave-cloud-client

A minimal implementation of the REST interface used to communicate with D-Wave Solver API (SAPI) servers.

PythonApache-2.0

62 stars · Updated 3mo ago

dwavesystems

dwave-ocean-sdk

Installer for D-Wave's Ocean tools

PythonApache-2.0FlagshipQtangl relevant

524 stars · Updated 3mo ago

dwavesystems

dwave_embedding_utilities

Provides utilities for mapping between source and target models.

PythonApache-2.0Archive

11 stars · Updated 8y ago

dwavesystems

qbsolv

Qbsolv,a decomposing solver, finds a minimum value of a large quadratic unconstrained binary optimization (QUBO) problem by splitting it into pieces solved either via a D-Wave system or a classical tabu solver.

qApache-2.0FlagshipQtangl relevantArchive

920 stars · Updated 4y ago