|
| 1 | +### A Pluto.jl notebook ### |
| 2 | +# v0.19.4 |
| 3 | + |
| 4 | +using Markdown |
| 5 | +using InteractiveUtils |
| 6 | + |
| 7 | +# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). |
| 8 | +macro bind(def, element) |
| 9 | + quote |
| 10 | + local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end |
| 11 | + local el = $(esc(element)) |
| 12 | + global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) |
| 13 | + el |
| 14 | + end |
| 15 | +end |
| 16 | + |
| 17 | +# ╔═╡ 77211b40-3e1b-46dc-b803-07c0ba8cbf60 |
| 18 | +using Pkg; Pkg.activate() |
| 19 | + |
| 20 | +# ╔═╡ ababcad9-415c-4a1e-97a5-322a15e98c80 |
| 21 | +using Revise, GenericTensorNetworks, Graphs, PlutoUI |
| 22 | + |
| 23 | +# ╔═╡ 9d955aa6-f8dc-4a16-a883-60d3ddf61636 |
| 24 | +graph = Graphs.smallgraph(:petersen) |
| 25 | + |
| 26 | +# ╔═╡ 83b69249-53cd-4f88-953d-caba7d4a4b25 |
| 27 | +# set the vertex locations manually instead of using the default spring layout |
| 28 | +rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a |
| 29 | + |
| 30 | +# ╔═╡ 1520b6a8-79cb-49c2-8ea8-a84bb2120158 |
| 31 | +locations = [[rot15(0.0, 1.0, i) for i=0:4]..., [rot15(0.0, 0.5, i) for i=0:4]...] |
| 32 | + |
| 33 | +# ╔═╡ 3bd9bf83-2dd2-4800-bc56-dd41985a82a0 |
| 34 | +show_graph(graph; locs=locations, scale=0.6) |
| 35 | + |
| 36 | +# ╔═╡ 8138f684-cdbd-4d43-aff3-f1d80ae090e1 |
| 37 | +problem = IndependentSet(graph; optimizer=TreeSA()); |
| 38 | + |
| 39 | +# ╔═╡ 23744442-aeb1-4bdf-b87f-69c27853f2a7 |
| 40 | +max_config = solve(problem, SingleConfigMax())[] |
| 41 | + |
| 42 | +# ╔═╡ 204d0632-32b1-416d-903d-8d253f65d44f |
| 43 | +single_solution = max_config.c.data |
| 44 | + |
| 45 | +# ╔═╡ d5446d05-a80c-4d37-8549-f440b7067d6e |
| 46 | +show_graph(graph; locs=locations, vertex_colors= |
| 47 | + [iszero(single_solution[i]) ? "white" : "red" for i=1:nv(graph)], scale=0.6) |
| 48 | + |
| 49 | +# ╔═╡ 5d71602e-fd6e-4a63-9cbe-f359538bf20e |
| 50 | +show_graph(graph; locs=locations, vertex_colors= |
| 51 | + [iszero(x) ? "white" : "red" for x in [0, 1, 0, 0, 0, 1, 0, 0, 0, 0]], scale=0.6) |
| 52 | + |
| 53 | +# ╔═╡ 847bcb04-a706-4d45-92b9-8ef754520b5a |
| 54 | +wrong_solution = [true, false, true, false, false, true, false, false, false, true] |
| 55 | + |
| 56 | +# ╔═╡ 5ebb1b2b-9fe7-44b5-bb0d-10889950fe56 |
| 57 | +show_graph(graph; locs=locations, vertex_colors= |
| 58 | + [iszero(wrong_solution[i]) ? "white" : "red" for i=1:nv(graph)], scale=0.6) |
| 59 | + |
| 60 | +# ╔═╡ 90f10354-a77f-43c3-9033-1e175886fc2f |
| 61 | +poly = solve(problem, GraphPolynomial())[] |
| 62 | + |
| 63 | +# ╔═╡ 91fcc8db-b11b-4c1e-bec2-85507536c86b |
| 64 | +max_configs2 = solve(problem, ConfigsMax(5))[] |
| 65 | + |
| 66 | +# ╔═╡ 5e952998-a7d3-44a6-bcdb-b7cd6a0b7f74 |
| 67 | +@bind iconfig NumberField(0:4) |
| 68 | + |
| 69 | +# ╔═╡ 64f35113-5590-4e0d-99ff-6350083c77a1 |
| 70 | +show_gallery(graph, (ceil(Int, length(max_configs2.coeffs[iconfig+1])/5), 5); locs=locations, vertex_configs=max_configs2.coeffs[iconfig+1], image_size=3.5, scale=0.6) |
| 71 | + |
| 72 | +# ╔═╡ Cell order: |
| 73 | +# ╠═77211b40-3e1b-46dc-b803-07c0ba8cbf60 |
| 74 | +# ╠═ababcad9-415c-4a1e-97a5-322a15e98c80 |
| 75 | +# ╠═9d955aa6-f8dc-4a16-a883-60d3ddf61636 |
| 76 | +# ╠═83b69249-53cd-4f88-953d-caba7d4a4b25 |
| 77 | +# ╠═1520b6a8-79cb-49c2-8ea8-a84bb2120158 |
| 78 | +# ╠═3bd9bf83-2dd2-4800-bc56-dd41985a82a0 |
| 79 | +# ╠═8138f684-cdbd-4d43-aff3-f1d80ae090e1 |
| 80 | +# ╠═23744442-aeb1-4bdf-b87f-69c27853f2a7 |
| 81 | +# ╠═204d0632-32b1-416d-903d-8d253f65d44f |
| 82 | +# ╠═d5446d05-a80c-4d37-8549-f440b7067d6e |
| 83 | +# ╠═5d71602e-fd6e-4a63-9cbe-f359538bf20e |
| 84 | +# ╠═847bcb04-a706-4d45-92b9-8ef754520b5a |
| 85 | +# ╠═5ebb1b2b-9fe7-44b5-bb0d-10889950fe56 |
| 86 | +# ╠═90f10354-a77f-43c3-9033-1e175886fc2f |
| 87 | +# ╠═91fcc8db-b11b-4c1e-bec2-85507536c86b |
| 88 | +# ╟─5e952998-a7d3-44a6-bcdb-b7cd6a0b7f74 |
| 89 | +# ╠═64f35113-5590-4e0d-99ff-6350083c77a1 |
0 commit comments