-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
weights(::AbstractITensorNetwork)
, new graph partitioning inter…
…face
- Loading branch information
Showing
30 changed files
with
793 additions
and
360 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
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
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
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,20 @@ | ||
using NamedGraphs | ||
using ITensors | ||
using ITensorNetworks | ||
using ITensorUnicodePlots | ||
using Metis | ||
|
||
tn = ITensorNetwork(named_grid((6, 3)); link_space=4) | ||
|
||
@visualize tn | ||
|
||
g = subgraph_vertices(tn; nvertices_per_partition=2) | ||
sub_vs_1, sub_vs_2 = g[1], g[2] | ||
|
||
@show (1, 1) ∈ sub_vs_1 | ||
@show (6, 3) ∈ sub_vs_2 | ||
|
||
@show boundary_edges(tn, sub_vs_1) | ||
@show boundary_vertices(tn, sub_vs_1) | ||
@show inner_boundary_vertices(tn, sub_vs_1) | ||
@show outer_boundary_vertices(tn, sub_vs_1) |
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,17 @@ | ||
using NamedGraphs | ||
using ITensors | ||
using ITensorNetworks | ||
using ITensorUnicodePlots | ||
|
||
g = named_grid((3, 5)) | ||
s = siteinds("S=1/2", g) | ||
ψ = ITensorNetwork(s; link_space=4) | ||
@visualize ψ | ||
@show center(ψ) | ||
@show periphery(ψ) | ||
t = dijkstra_tree(ψ, only(center(ψ))) | ||
@visualize t | ||
@show a_star(ψ, (2, 1), (2, 5)) | ||
@show mincut_partitions(ψ) | ||
@show mincut_partitions(ψ, (1, 1), (3, 5)) | ||
@show subgraph_vertices(ψ; npartitions=2) |
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,17 @@ | ||
using ITensors | ||
using Graphs | ||
using NamedGraphs | ||
using ITensorNetworks | ||
using SplitApplyCombine | ||
using Metis | ||
|
||
s = siteinds("S=1/2", named_grid(8)) | ||
tn = ITensorNetwork(s; link_space=2) | ||
Z = prime(tn; sites=[]) ⊗ tn | ||
vertex_groups = group(v -> v[1], vertices(Z)) | ||
# Create two layers of partitioning | ||
Z_p = partition(partition(Z, vertex_groups); nvertices_per_partition=2) | ||
# Flatten the partitioned partitions | ||
Z_verts = [ | ||
reduce(vcat, (vertices(Z_p[vp][v]) for v in vertices(Z_p[vp]))) for vp in vertices(Z_p) | ||
] |
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,55 @@ | ||
using NamedGraphs | ||
using ITensors | ||
using ITensorNetworks | ||
using ITensorUnicodePlots | ||
|
||
g = named_grid(5) | ||
s = siteinds("S=1/2", g) | ||
|
||
ψ = ITensorNetwork(s; link_space=10) | ||
|
||
# ρ = flatten_networks(dag(ψ), ψ') | ||
|
||
# Or: | ||
|
||
ss = ∪(dag(s), s'; merge_data=union) | ||
ρ = ITensorNetwork(ss; link_space=2) | ||
|
||
tn = ⊗(ρ', ρ, ψ) | ||
tn_flattened = flatten_networks(ρ', ρ, ψ) | ||
# tn = ρ' ⊗ ρ ⊗ ψ | ||
@visualize tn | ||
|
||
@show center(tn) | ||
|
||
v = first(center(tn)) | ||
|
||
dijk_parents = dijkstra_parents(tn, v) | ||
dijk_mst = dijkstra_mst(tn, v) | ||
dijk_tree = dijkstra_tree(tn, v) | ||
|
||
bfs_tree_tn = bfs_tree(tn, v) | ||
|
||
@show eccentricity(tn, v) | ||
@show radius(tn) | ||
@show radius(tn) | ||
@show diameter(tn) | ||
@show periphery(tn) | ||
|
||
s = dijk_tree | ||
t = bfs_tree_tn | ||
@visualize s | ||
@visualize t | ||
|
||
v1 = first(periphery(tn)) | ||
nds = neighborhood_dists(tn, v1, nv(tn)) | ||
d_and_i = findmax(vd -> vd[2], nds) | ||
v2 = nds[d_and_i[2]][1] | ||
@show v1, v2 | ||
p1, p2 = mincut_partitions(tn, v1, v2) | ||
@show p1 | ||
@show p2 | ||
|
||
display(adjacency_matrix(tn_flattened)) | ||
tn_flattened_p = symrcm_permute(tn_flattened) | ||
display(adjacency_matrix(tn_flattened_p)) |
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
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
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,16 @@ | ||
using NamedGraphs | ||
using ITensors | ||
using ITensorNetworks | ||
using ITensorUnicodePlots | ||
|
||
tn = ITensorNetwork(named_grid((3, 5)); link_space=4) | ||
|
||
@visualize tn | ||
|
||
terminal_vertices = [(1, 2), (1, 4), (3, 4)] | ||
st = steiner_tree(tn, terminal_vertices) | ||
|
||
@show has_edge(st, (1, 2) => (1, 3)) | ||
@show has_edge(st, (1, 3) => (1, 4)) | ||
@show has_edge(st, (1, 4) => (2, 4)) | ||
@show has_edge(st, (2, 4) => (3, 4)) |
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
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
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
Oops, something went wrong.