Visualizing quantum walks on small graphs
This page has all the Julia code necessary for creating the images; as such, it must begin with a couple of trivialities, as loading the dependencies and defining the adjacency matrix of a graph.
xxxxxxxxxxbegin using LinearAlgebra using LightGraphs using Plots using Printfendadjacency_matrix (generic function with 2 methods)xxxxxxxxxxbegin function adjacency_matrix(n :: Int64, e :: AbstractEdge) f(i :: Int64) = [ convert(Float64, i == j) for j in 1:n ] f(src(e)) .* f(dst(e))' + f(dst(e)) .* f(src(e))' end function adjacency_matrix(G :: SimpleGraph) f(e) = adjacency_matrix(nv(G), e) sum(f.(edges(G))) endendQuantum Walk representation
I am representing a quantum walk as the adjacency matrix of the graph.
QuantumWalkbegin struct QuantumWalk A :: Matrix end function QuantumWalk(G :: SimpleGraph) QuantumWalk(adjacency_matrix(G)) endendI also created a custom heatmap function for displaying the matrices.
heatmap (generic function with 1 method)xxxxxxxxxxfunction heatmap(A :: Matrix; kargs...) Plots.heatmap(A; clim=(0.0, 1.0), framestyle = :none, ticks = false, aspectratio = :equal, c = :thermal, kargs... )endThen it is easy to create an animation: Just iterate over a bunch of times and display the component-wise absolute value of
animate (generic function with 1 method)x
function animate(walk :: QuantumWalk, t0 :: Float64, t1 :: Float64) step = (t1 - t0)/200 animation = for t in t0:step:t1 heatmap(abs.(exp(im * t * walk.A)), title= ("t = %.2f", t),) end gif(animation, fps=10)endVisualizations
I can now display some quantum walks. I will show for
xxxxxxxxxxanimate(QuantumWalk(path_graph(2)), 0.0, 2.0 * pi)x
animate(QuantumWalk(path_graph(3)), 0.0, sqrt(2) * pi)We can also observe the instantaneous uniform mixing of the claw graph at
.
xxxxxxxxxxbegin claw_graph = SimpleGraph(4) for i in 2:4 add_edge!(claw_graph, 1, i) end animate(QuantumWalk(claw_graph), 0.0, 4.0 * pi / (3 * sqrt(3)))endCartesian product
There are two interesting things to do with the cartesian product. The first one is to watch how the quantum walk on the cartesian product reduces to the kronecker product in each matrix.
visualize_product (generic function with 1 method)xxxxxxxxxxfunction visualize_product(G :: SimpleGraph, H :: SimpleGraph, t0 :: Float64, t1 :: Float64) step = (t1 - t0)/200 custom_heatmap(graph, t) = heatmap(abs.(exp(im * t * adjacency_matrix(graph))), colorbar = false, title = "") animation = for t in t0:step:t1 plot( custom_heatmap(cartesian_product(G, H), t), custom_heatmap(H, t), custom_heatmap(G, t), layout=3, plot_title = "t = $(t)" ) end gif(animation, fps=10)endxxxxxxxxxxvisualize_product(path_graph(2), path_graph(2), 0.0, 2 * pi)xxxxxxxxxxvisualize_product(path_graph(3), path_graph(3), 0.0, sqrt(2) * pi)xxxxxxxxxxvisualize_product(path_graph(2), path_graph(3), 0.0, 2.0 * pi)We may also consider the cartesian powers of a graph, and visualize the behavior of the quantum walks on them.
cartesian_power (generic function with 1 method)xxxxxxxxxxfunction cartesian_power(G :: SimpleGraph, k :: Int64) if k == 0 SimpleGraph(1) else cartesian_product(G, cartesian_power(G, k - 1)) endendxxxxxxxxxxanimate(QuantumWalk(cartesian_power(path_graph(2), 2)), 0.0, 2.0 * pi)xxxxxxxxxxanimate(QuantumWalk(cartesian_power(path_graph(3), 4)), 0.0, sqrt(2) * pi)