Last active
May 30, 2021 15:09
-
-
Save hexaeder/93b9adaffb9a90799cc89780c81c0ec3 to your computer and use it in GitHub Desktop.
hacky script to create and plot depgraph of package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Author
hexaeder
commented
May 30, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment