# Weighted random-geometric Graph 3D

# Adaptation from:
# L Alonso, et. al. https://doi.org/10.1093/comnet/cnx053

using LinearAlgebra, Random, GLMakie
GLMakie.activate!()

Random.seed!(rseed)
xy = rand(nodes, 3)
x = xy[:, 1]
y = xy[:, 2]
z = xy[:, 3]

for point in 1:nodes-1
xseps = (x[point+1:end] .- x[point]) .^ 2
yseps = (y[point+1:end] .- y[point]) .^ 2
zseps = (z[point+1:end] .- z[point]) .^ 2

distance = sqrt.(xseps .+ yseps .+ zseps)
dindx = findall(distance .<= radius) .+ point
if length(dindx) > 0
rnd = randn(length(dindx))
end
end
end

xyzos = []
weights = []
for i in eachindex(x), j in i+1:length(x)
push!(xyzos, [x[i], y[i], z[i]])
push!(xyzos, [x[j], y[j], z[j]])
end
end
return (Point3f.(xyzos), Float32.(weights))
end

cmap = (:Hiroshige, 0.75)
segm, weights = getGraphEdges3D(adjacencyM3D, x, y, z)

fig, ax, pltobj = linesegments(segm; color = weights, colormap = cmap,
linewidth = abs.(weights),
figure = (;
resolution = (1200, 800),
fontsize = 24),
axis = (;
type = Axis3,
aspect = (1, 1, 1),
perspectiveness = 0.5))
meshscatter!(ax, x, y, z; color = diagValues,
markersize = abs.(diagValues) ./ 90,
colormap = cmap)
Colorbar(fig[1, 2], pltobj, label = "weights", height = Relative(0.5))
colsize!(fig.layout, 1, Aspect(1, 1.0))
fig
end
with_theme(theme_dark()) do
end Warning

This example was autogenerated using:

using Pkg
Pkg.status(["GLMakie", "LinearAlgebra"])

Status ~/work/BeautifulMakie/BeautifulMakie/docs/Project.toml
[e9467ef8] GLMakie v0.8.6
[37e2e46d] LinearAlgebra