Skip to content

Instantly share code, notes, and snippets.

@hexaeder
Last active May 30, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hexaeder/93b9adaffb9a90799cc89780c81c0ec3 to your computer and use it in GitHub Desktop.
Save hexaeder/93b9adaffb9a90799cc89780c81c0ec3 to your computer and use it in GitHub Desktop.
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
Copy link
Author

hexaeder commented May 30, 2021

grafik

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