Skip to content

Commit

Permalink
Update docstring for load_from_networkx
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarhiggott committed Sep 5, 2021
1 parent c13980b commit 3a3b887
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/pymatching/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def add_edge(
error_probability, has_error_probability)

def load_from_networkx(self, graph: nx.Graph) -> None:
"""
r"""
Load a matching graph from a NetworkX graph
Parameters
Expand All @@ -222,13 +222,10 @@ def load_from_networkx(self, graph: nx.Graph) -> None:
`m` in `G` should be an integer :math:`0<m<M-1`, and each node should
be unique. Each edge in the NetworkX graph can have optional
attributes ``qubit_id``, ``weight`` and ``error_probability``.
``qubit_id`` should be an int or a set of ints. If there
are :math:`N` qubits then the union of all ints in the ``qubit_id``
attributes in the graph should be the integers :math:`0\ldots N-1`.
``qubit_id`` should be an int or a set of ints.
Note that the ``qubit_id`` attribute can instead be used to store the indices
of logical observables flipped by an error on the corresponding edge
(e.g. a frame change in an error instruction in a stim detector error model).
If there are N logical observables, they should again be numbered :math:`0\ldots N-1`.
Each ``weight`` attribute should be a non-negative float. If
every edge is assigned an error_probability between zero and one,
then the ``add_noise`` method can be used to simulate noise and
Expand All @@ -242,8 +239,8 @@ def load_from_networkx(self, graph: nx.Graph) -> None:
>>> g = nx.Graph()
>>> g.add_edge(0, 1, qubit_id=0, weight=math.log((1-0.1)/0.1), error_probability=0.1)
>>> g.add_edge(1, 2, qubit_id=1, weight=math.log((1-0.15)/0.15), error_probability=0.15)
>>> g.node[0]['is_boundary'] = True
>>> g.node[2]['is_boundary'] = True
>>> g.nodes[0]['is_boundary'] = True
>>> g.nodes[2]['is_boundary'] = True
>>> m = pymatching.Matching(g)
>>> m
<pymatching.Matching object with 2 qubits, 1 detector, 2 boundary nodes, and 2 edges>
Expand Down

0 comments on commit 3a3b887

Please sign in to comment.