Skip to content

Instantly share code, notes, and snippets.

@hexaeder
Last active May 30, 2021
Embed
What would you like to do?
hacky script to create and plot depgraph of package
using Pkg
Pkg.activate(temp=true)
Pkg.add("PkgDeps")
Pkg.add("LightGraphs")
Pkg.add("GLMakie")
Pkg.add(url="https://github.com/JuliaPlots/GraphMakie.jl", rev="arrowheads")
using PkgDeps
using LightGraphs
using GLMakie
using GraphMakie
function depgraph(root)
packages = [root]
connections = Vector{Pair{Int,Int}}()
for pkg in packages
println("Check ", pkg)
pkgidx = findfirst(isequal(pkg), packages)
deps = Dict{String, Base.UUID}()
try
deps = direct_dependencies(pkg)
catch
continue # probably in std lib?
end
for dep in keys(deps)
idx = findfirst(isequal(dep), packages)
if idx === nothing
push!(packages, dep)
idx = lastindex(packages)
end
push!(connections, idx => pkgidx)
end
end
g = SimpleDiGraph(length(packages))
for c in connections
add_edge!(g, c)
end
return (packages, g)
end
(packages, g) = depgraph("PkgDeps")
node_size = vcat(50, [20 for i in 2:nv(g)])
node_color = vcat(:green, [:black for i in 2:nv(g)])
f, ax, p = graphplot(g; nlabels=packages, nlabels_size=30, nlabels_color=:red, node_color, node_size)
hidedecorations!(ax)
@hexaeder

This comment has been minimized.

Copy link
Owner Author

@hexaeder hexaeder commented May 30, 2021

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment