Skip to content

Commit 66845a9

Browse files
committed
fix documentation
1 parent e4e1e5a commit 66845a9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

docs/Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
GenericTensorNetworks = "3521c873-ad32-4bb4-b63d-f4f178f42b49"
3+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
44
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
55
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
6+
LuxorGraphPlot = "1f49bdf2-22a7-4bc4-978b-948dc219fbbc"
67
ProblemReductions = "899c297d-f7d2-4ebf-8815-a35996def416"
78
TensorInference = "c2297e78-99bd-40ad-871d-f50e56b81012"
89
TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d"

examples/hard-core-lattice-gas/main.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ sites = vec([50 .* (a .* i .+ b .* j) for i=1:Na, j=1:Nb])
2020
# There exists blockade interactions between hard-core particles.
2121
# We connect two lattice sites within blockade radius by an edge.
2222
# Two ends of an edge can not both be occupied by particles.
23-
blockade_radius = 55
24-
using GenericTensorNetworks: show_graph, unit_disk_graph
25-
using GenericTensorNetworks.Graphs: edges, nv
26-
graph = unit_disk_graph(vec(sites), blockade_radius)
27-
show_graph(graph, sites; texts=fill("", length(sites)))
23+
blockade_radius = 55.0
24+
using LuxorGraphPlot: show_graph, GraphDisplayConfig
25+
using Graphs: edges, nv, SimpleGraph
26+
using TensorInference.ProblemReductions: UnitDiskGraph, IndependentSet
27+
graph = UnitDiskGraph(vec(sites), blockade_radius)
28+
show_graph(SimpleGraph(graph), sites; texts=fill("", length(sites)))
2829

2930
# These constraints defines an independent set problem that characterized by the following energy based model.
3031
# Let $G = (V, E)$ be a graph, where $V$ is the set of vertices and $E$ is the set of edges.
@@ -38,7 +39,6 @@ show_graph(graph, sites; texts=fill("", length(sites)))
3839
# The solution space hard-core lattice gas is equivalent to that of an independent set problem.
3940
# The independent set problem involves finding a set of vertices in a graph such that no two vertices in the set are adjacent (i.e., there is no edge connecting them).
4041
# One can create a tensor network based modeling of an independent set problem with package [`GenericTensorNetworks.jl`](https://github.com/QuEraComputing/GenericTensorNetworks.jl).
41-
using GenericTensorNetworks
4242
problem = IndependentSet(graph)
4343

4444
# There are plenty of discussions related to solution space properties in the `GenericTensorNetworks` [documentaion page](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/IndependentSet/).
@@ -59,14 +59,14 @@ partition_func[]
5959

6060
# The marginal probabilities can be computed with the [`marginals`](@ref) function, which measures how likely a site is occupied.
6161
mars = marginals(pmodel)
62-
show_graph(graph, sites; vertex_colors=[(b = mars[[i]][2]; (1-b, 1-b, 1-b)) for i in 1:nv(graph)], texts=fill("", nv(graph)))
62+
show_graph(SimpleGraph(graph), sites; vertex_colors=[(b = mars[[i]][2]; (1-b, 1-b, 1-b)) for i in 1:nv(graph)], texts=fill("", nv(graph)))
6363
# The can see the sites at the corner is more likely to be occupied.
6464
# To obtain two-site correlations, one can set the variables to query marginal probabilities manually.
6565
pmodel2 = TensorNetworkModel(problem, β; mars=[[e.src, e.dst] for e in edges(graph)])
6666
mars = marginals(pmodel2);
6767

6868
# We show the probability that both sites on an edge are not occupied
69-
show_graph(graph, sites; edge_colors=[(b = mars[[e.src, e.dst]][1, 1]; (1-b, 1-b, 1-b)) for e in edges(graph)], texts=fill("", nv(graph)), config=GraphDisplayConfig(; edge_line_width=5))
69+
show_graph(SimpleGraph(graph), sites; edge_colors=[(b = mars[[e.src, e.dst]][1, 1]; (1-b, 1-b, 1-b)) for e in edges(graph)], texts=fill("", nv(graph)), config=GraphDisplayConfig(; edge_line_width=5))
7070

7171
# ## The most likely configuration
7272
# The MAP and MMAP can be used to get the most likely configuration given an evidence.
@@ -77,7 +77,7 @@ mars = marginals(pmodel3)
7777
logp, config = most_probable_config(pmodel3)
7878

7979
# The log probability is 102. Let us visualize the configuration.
80-
show_graph(graph, sites; vertex_colors=[(1-b, 1-b, 1-b) for b in config], texts=fill("", nv(graph)))
80+
show_graph(SimpleGraph(graph), sites; vertex_colors=[(1-b, 1-b, 1-b) for b in config], texts=fill("", nv(graph)))
8181
# The number of particles is
8282
sum(config)
8383

@@ -86,7 +86,7 @@ pmodel3 = TensorNetworkModel(problem, β; evidence=Dict(1=>0))
8686
logp2, config2 = most_probable_config(pmodel)
8787

8888
# The log probability is 99, which is much smaller.
89-
show_graph(graph, sites; vertex_colors=[(1-b, 1-b, 1-b) for b in config2], texts=fill("", nv(graph)))
89+
show_graph(SimpleGraph(graph), sites; vertex_colors=[(1-b, 1-b, 1-b) for b in config2], texts=fill("", nv(graph)))
9090
# The number of particles is
9191
sum(config2)
9292

0 commit comments

Comments
 (0)