dwave.graphs.markov_network#

markov_network(potentials: Mapping[Hashable, Mapping[Hashable, float]]) Graph[source]#

Creates a Markov network from potentials.

A Markov network is also knows as a Markov Random Field

Parameters:

potentials – A mapping where the keys are either nodes or edges and the values are a mapping of potentials. The potential dict should map each possible assignment of the nodes/edges to their energy.

Returns:

A markov network as a NetworkX graph where each node/edge stores its potential dict as above.

Example: >>> potentials = {(‘a’, ‘b’): {(0, 0): -1, … (0, 1): .5, … (1, 0): .5, … (1, 1): 2}} >>> MN = dwave.graphs.markov_network(potentials) >>> MN[‘a’][‘b’][‘potential’][(0, 0)] -1