init with working graph
This commit is contained in:
commit
53d095be9e
5 changed files with 1640 additions and 0 deletions
13
.JuliaFormatter.toml
Normal file
13
.JuliaFormatter.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
# See https://domluna.github.io/JuliaFormatter.jl/stable/ for a list of options
|
||||
whitespace_ops_in_indices = true
|
||||
remove_extra_newlines = true
|
||||
always_for_in = true
|
||||
whitespace_typedefs = true
|
||||
normalize_line_endings = "unix"
|
||||
# format_docstrings = true
|
||||
# format_markdown = true
|
||||
align_assignment = true
|
||||
align_struct_field = true
|
||||
align_conditional = true
|
||||
align_pair_arrow = true
|
||||
align_matrix = true
|
1539
Manifest.toml
Normal file
1539
Manifest.toml
Normal file
File diff suppressed because it is too large
Load diff
13
Project.toml
Normal file
13
Project.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
name = "PkgDependencyGraph"
|
||||
uuid = "39c25c91-4e8c-4909-a03e-edcf53c12019"
|
||||
authors = ["qwjyh <urataw421@gmail.com>"]
|
||||
version = "0.1.0"
|
||||
|
||||
[deps]
|
||||
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
|
||||
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
|
||||
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
|
||||
MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
|
||||
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"
|
||||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
|
||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
70
main.jl
Normal file
70
main.jl
Normal file
|
@ -0,0 +1,70 @@
|
|||
using Pkg
|
||||
using UUIDs
|
||||
using Graphs
|
||||
using MetaGraphsNext
|
||||
using GLMakie
|
||||
using GraphMakie
|
||||
|
||||
g = MetaGraph(
|
||||
SimpleDiGraph(),
|
||||
label_type = UUID,
|
||||
vertex_data_type = Pkg.API.PackageInfo,
|
||||
edge_data_type = Bool,
|
||||
)
|
||||
|
||||
foreach(Pkg.dependencies()) do (k_pkguuid, v_pkginfo)
|
||||
g[k_pkguuid] = v_pkginfo
|
||||
end
|
||||
|
||||
foreach(Pkg.dependencies()) do (pkguuid, pkginfo)
|
||||
foreach(pkginfo.dependencies) do (dep_pkgname, dep_pkguuid)
|
||||
g[pkguuid, dep_pkguuid] = true
|
||||
end
|
||||
end
|
||||
|
||||
fig, ax, p = graphplot(
|
||||
g;
|
||||
node_color = fill((:black, 0.9), nv(g)),
|
||||
node_size = fill(10, nv(g)),
|
||||
edge_color = fill((:gray, 0.8), ne(g)),
|
||||
nlabels = labels(g) .|> (k -> g[k].name),
|
||||
)
|
||||
|
||||
deregister_interaction!(ax, :rectanglezoom)
|
||||
register_interaction!(ax, :nodedrag, NodeDrag(p))
|
||||
register_interaction!(
|
||||
ax,
|
||||
:nodehover,
|
||||
NodeHoverHandler() do hoverstate, idx, event, axis
|
||||
p.node_color[][idx] = hoverstate ? (:yellow, 0.9) : (:black, 0.9)
|
||||
p.node_size[][idx] = hoverstate ? 20 : 10
|
||||
foreach(inneighbors(g, idx)) do didx
|
||||
edge_id = findfirst(==(Edge(didx, idx)), edges(g) |> collect)
|
||||
p.edge_color[][edge_id] = hoverstate ? (:blue, 0.8) : (:gray, 0.8)
|
||||
end
|
||||
foreach(outneighbors(g, idx)) do sidx
|
||||
edge_id = findfirst(==(Edge(idx, sidx)), edges(g) |> collect)
|
||||
p.edge_color[][edge_id] = hoverstate ? (:red, 0.8) : (:gray, 0.8)
|
||||
end
|
||||
p.node_color[] = p.node_color[]
|
||||
p.node_size[] = p.node_size[]
|
||||
p.edge_color[] = p.edge_color[]
|
||||
end,
|
||||
)
|
||||
|
||||
tb1_pkgname = Textbox(fig[2, 1], tellwidth = false)
|
||||
on(tb1_pkgname.stored_string) do s
|
||||
pkgnames = labels(g) .|> (k -> g[k].name)
|
||||
@info "textbox" s
|
||||
if all(!=(s), pkgnames)
|
||||
return nothing
|
||||
end
|
||||
idx = findfirst(==(s), pkgnames)
|
||||
@info "match" idx
|
||||
p.node_color[][idx] = (:green, 0.6)
|
||||
p.node_size[][idx] = 20
|
||||
p.node_color[] = p.node_color[]
|
||||
p.node_size[] = p.node_size[]
|
||||
end
|
||||
|
||||
fig
|
5
src/PkgDependencyGraph.jl
Normal file
5
src/PkgDependencyGraph.jl
Normal file
|
@ -0,0 +1,5 @@
|
|||
module PkgDependencyGraph
|
||||
|
||||
greet() = print("Hello World!")
|
||||
|
||||
end # module PkgDependencyGraph
|
Loading…
Reference in a new issue