Loading [MathJax]/jax/output/HTML-CSS/jax.js

qml.qaoa.cycle.out_flow_constraint

out_flow_constraint(graph)[source]

Calculates the out flow constraint Hamiltonian for the maximum-weighted cycle problem.

Given a subset of edges in a directed graph, the out-flow constraint imposes that at most one edge can leave any given node, i.e., for all i:

j,(i,j)Exij1,

where E are the edges of the graph and xij is a binary number that selects whether to include the edge (i,j).

A set of edges satisfies the out-flow constraint whenever the following Hamiltonian is minimized:

iV(douti(douti2)I2(douti1)j,(i,j)EˆZij+(j,(i,j)EˆZij)2)

where V are the graph vertices, douti is the outdegree of node i, and Zij is a qubit Pauli-Z matrix acting upon the qubit specified by the pair (i,j). Mapping from edges to wires can be achieved using edges_to_wires().

Parameters

graph (nx.DiGraph or rx.PyDiGraph) – the directed graph specifying possible edges

Returns

the out flow constraint Hamiltonian

Return type

qml.Hamiltonian

Raises

ValueError – if the input graph is not directed