-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68dfbb5
commit 1fbbfe0
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Example code for finding causal flow.""" | ||
|
||
# %% | ||
|
||
from __future__ import annotations | ||
|
||
import networkx as nx | ||
from fastflow import flow | ||
|
||
g: nx.Graph[int] | ||
|
||
# %% | ||
|
||
# 1 - 3 - 5 | ||
# | | ||
# 2 - 4 - 6 | ||
g = nx.Graph([(1, 3), (2, 4), (3, 5), (4, 6)]) | ||
iset = {1, 2} | ||
oset = {5, 6} | ||
|
||
result = flow.find(g, iset, oset) | ||
|
||
# Found | ||
assert result is not None | ||
|
||
# %% | ||
|
||
# 1 - 3 | ||
# \ / | ||
# X | ||
# / \ | ||
# 2 - 4 | ||
g = nx.Graph([(1, 3), (1, 4), (2, 3), (2, 4)]) | ||
iset = {1, 2} | ||
oset = {3, 4} | ||
|
||
# Not found | ||
result = flow.find(g, iset, oset) | ||
|
||
assert result is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Example code for finding generalized flow.""" | ||
|
||
# %% | ||
|
||
from __future__ import annotations | ||
|
||
import networkx as nx | ||
from fastflow import gflow | ||
from fastflow.common import Plane | ||
|
||
g: nx.Graph[int] | ||
|
||
# %% | ||
|
||
# 0 - 1 | ||
# /| | | ||
# 4 | | | ||
# \| | | ||
# 2 - 5 - 3 | ||
g = nx.Graph([(0, 1), (0, 2), (0, 4), (1, 5), (2, 4), (2, 5), (3, 5)]) | ||
iset = {0, 1} | ||
oset = {4, 5} | ||
planes = {0: Plane.XY, 1: Plane.XY, 2: Plane.XZ, 3: Plane.YZ} | ||
|
||
result = gflow.find(g, iset, oset, planes) | ||
|
||
# Found | ||
assert result is not None | ||
|
||
# %% | ||
|
||
# 1 - 3 | ||
# \ / | ||
# X | ||
# / \ | ||
# 2 - 4 | ||
g = nx.Graph([(1, 3), (1, 4), (2, 3), (2, 4)]) | ||
iset = {1, 2} | ||
oset = {3, 4} | ||
# Omitting planes (all Plane.XY) | ||
|
||
result = gflow.find(g, iset, oset) | ||
|
||
# Not found | ||
assert result is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Example code for finding Pauli flow.""" | ||
|
||
# %% | ||
|
||
from __future__ import annotations | ||
|
||
import networkx as nx | ||
from fastflow import pflow | ||
from fastflow.common import PPlane | ||
|
||
g: nx.Graph[int] | ||
|
||
# %% | ||
|
||
# 1 2 3 | ||
# | / | | ||
# 0 - - - 4 | ||
g = nx.Graph([(0, 1), (0, 2), (0, 4), (3, 4)]) | ||
iset = {0} | ||
oset = {4} | ||
pplanes = {0: PPlane.Z, 1: PPlane.Z, 2: PPlane.Y, 3: PPlane.Y} | ||
|
||
result = pflow.find(g, iset, oset, pplanes) | ||
|
||
# Found | ||
assert result is not None | ||
|
||
# %% | ||
|
||
# 1 - 3 | ||
# \ / | ||
# X | ||
# / \ | ||
# 2 - 4 | ||
g = nx.Graph([(1, 3), (1, 4), (2, 3), (2, 4)]) | ||
iset = {1, 2} | ||
oset = {3, 4} | ||
# Omitting pplanes (all PPlane.XY) | ||
|
||
# NOTE: This results in warning (use gflow.find if pplanes has no Pauli measurements) | ||
result = pflow.find(g, iset, oset) | ||
|
||
# Not found | ||
assert result is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters