# Nazarathy and Klok, Listing 1.12 using Plots; pyplot() function graphCreator(n::Int) vertices = 1:n complexPts = [exp(2*pi*im*k/n) for k in vertices] coords = [(real(p),imag(p)) for p in complexPts] xPts = first.(coords) yPts = last.(coords) edges = [] for v in vertices, u in (v+1):n push!(edges,(v,u)) end anim = Animation() scatter(xPts, yPts, c=:blue, msw=0, ratio=1, xlims=(-1.5,1.5), ylims=(-1.5,1.5), legend=:none) for i in 1:length(edges) u, v = edges[i][1], edges[i][2] xpoints = [xPts[u], xPts[v]] ypoints = [yPts[u], yPts[v]] plot!(xpoints, ypoints, line=(:red)) frame(anim) end gif(anim, "D:\\julia\\test\\graph.gif", fps = 60) end graphCreator(16)
include("D:/julia/test/GphAnim.jl")