dwavesystems / minorminer

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.
https://docs.ocean.dwavesys.com/en/stable/docs_minorminer/source/sdk_index.html
Apache License 2.0
48 stars 40 forks source link

`insert_clique_embedding[s]` or similar #213

Closed arcondello closed 2 years ago

arcondello commented 2 years ago

I imagine something like

def insert_clique_embedding(embedding: Union[Dict[int, int], List[List[int]], target_graph: nx.Graph):
    ...

though not sure we can insert only one clique embedding. In which case something like

def insert_clique_embeddings(embeddings: Iterable[Union[Dict[int, int], List[List[int]]], target_graph: nx.Graph):
    ...
boothby commented 2 years ago

Today, you can already do the second with a bit of an off-label use of the internal functionality:

from minorminer import busclique
bgc_source = busclique.busgraph_cache(g)
emb0 = bgc_source.largest_clique() #computes a cache
clique_cache = bgc_source._fetch_cache('clique', lambda:()) #retrieves the cached cliques

bgc_target = busclique.busgraph_cache(g)
bgc_target._fetch_cache('clique', lambda: bgc_target) #injects the cached cliques to the new busgraph_cache object
emb1 = bgc_target.largest_clique()
assert emb0 == emb1