You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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).
40
40
# One can create a tensor network based modeling of an independent set problem with package [`GenericTensorNetworks.jl`](https://github.com/QuEraComputing/GenericTensorNetworks.jl).
41
41
using GenericTensorNetworks
42
-
problem =IndependentSet(graph; optimizer=GreedyMethod());
42
+
problem =IndependentSet(graph)
43
43
44
44
# There are plenty of discussions related to solution space properties in the `GenericTensorNetworks` [documentaion page](https://queracomputing.github.io/GenericTensorNetworks.jl/dev/generated/IndependentSet/).
45
45
# In this example, we show how to use `TensorInference` to use probabilistic inference for understand the finite temperature properties of this statistical model.
@@ -59,15 +59,14 @@ partition_func[]
59
59
60
60
# The marginal probabilities can be computed with the [`marginals`](@ref) function, which measures how likely a site is occupied.
61
61
mars =marginals(pmodel)
62
-
show_graph(graph; locs=sites, vertex_colors=[(b = mars[[i]][2]; (1-b, 1-b, 1-b)) for i in1:nv(graph)], texts=fill("", nv(graph)))
62
+
show_graph(graph, sites; vertex_colors=[(b = mars[[i]][2]; (1-b, 1-b, 1-b)) for i in1:nv(graph)], texts=fill("", nv(graph)))
63
63
# The can see the sites at the corner is more likely to be occupied.
64
64
# To obtain two-site correlations, one can set the variables to query marginal probabilities manually.
65
65
pmodel2 =TensorNetworkModel(problem, β; mars=[[e.src, e.dst] for e inedges(graph)])
66
66
mars =marginals(pmodel2);
67
67
68
68
# We show the probability that both sites on an edge are not occupied
69
-
show_graph(graph; locs=sites, edge_colors=[(b = mars[[e.src, e.dst]][1, 1]; (1-b, 1-b, 1-b)) for e inedges(graph)], texts=fill("", nv(graph)),
70
-
edge_line_widths=edge_colors=[8*mars[[e.src, e.dst]][1, 1] for e inedges(graph)])
69
+
show_graph(graph, sites; edge_colors=[(b = mars[[e.src, e.dst]][1, 1]; (1-b, 1-b, 1-b)) for e inedges(graph)], texts=fill("", nv(graph)), config=GraphDisplayConfig(; edge_line_width=5))
71
70
72
71
# ## The most likely configuration
73
72
# The MAP and MMAP can be used to get the most likely configuration given an evidence.
@@ -78,7 +77,7 @@ mars = marginals(pmodel3)
78
77
logp, config =most_probable_config(pmodel3)
79
78
80
79
# The log probability is 102. Let us visualize the configuration.
81
-
show_graph(graph; locs=sites, vertex_colors=[(1-b, 1-b, 1-b) for b in config], texts=fill("", nv(graph)))
80
+
show_graph(graph, sites; vertex_colors=[(1-b, 1-b, 1-b) for b in config], texts=fill("", nv(graph)))
0 commit comments