GraphRecipes.jl
GraphRecipes.jl copied to clipboard
Gallery
The examples section of the documentation is a list of examples that is designed to demonstrate the functionality of GraphRecipes with minimal overhead. Each example should be as simple as possible and should demonstrate one aspect of GraphRecipes. The purpose of a gallery would be to show off GraphRecipes features without the above restrictions. The gallery would have it's own page on the documentation. This project would work quite well in a team environment, since each person could work on a single example at a time and they could ask for feedback from other people in their team when they feel ready.
I will get the ball rolling right here:
Watts Strogatz
using GraphRecipes
using Plots
using LightGraphs
g = watts_strogatz(500, 10, 0.01)
graphplot(g, method=:spring, curves=false, color=:black, nodecolor=:red, nodesize=0.05, size=(800,800))
EDIT
GraphRecipes dependency graph
Credit goes to the original work at https://github.com/crstnbr/julia-ecosystem-dependencies
@crstnbr I thought that you should know that it is a possibility for your work to be used in the GraphRecipes gallery. Feel free to say no to the idea and we will not put the graph into the gallery
It might be possible to prune the code a little to get it slightly smaller. Also, we would have to think about whether we would want people to wait for the getalldeps
function to run, or if we should just make them download the provided BSON file. Also, hopefully the page where the gallery is hosted does a better job of viewing large images than github comments.
using DependenciesParser
using LightGraphs, GraphRecipes
using Plots
const ALLPKGS = DependenciesParser.data
const stdlibs = ["Base64", "CRC32c", "Dates", "DelimitedFiles",
"Distributed", "FileWatching", "Future", "InteractiveUtils",
"LibGit2", "Libdl", "LinearAlgebra", "Logging", "Markdown",
"Mmap", "Printf", "Profile", "REPL", "Random", "SHA", "Serialization",
"SharedArrays", "Sockets", "SparseArrays", "Statistics", "SuiteSparse",
"Test", "UUIDs", "Unicode", "Pkg"]
getdeps(pkg::AbstractString) = installable(pkg, direct=false)[2]
function getalldeps(pkgs=ALLPKGS)
deps = Dict{String,Vector{String}}()
for (idx, pkg) ∈ enumerate(pkgs)
deps[pkg] = getdeps(pkg)
end
deps
end
deps = getalldeps()
#=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This is much faster, although it requires people to download (and us to host) a BSON file.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=#
# using BSON
# deps = BSON.load("alldeps.bson")
# Drop stdlibs
deps = Dict(k => setdiff(v, stdlibs) for (k,v) in deps if !(k in stdlibs))
# Remove self-dependencies
for (k,v) in deps
k in v && filter!(!isequal(k), v)
end
function create_graph(pkgs, deps)
ps = pkgs
pkgs_deps = filter(p -> first(p) in ps, deps)
nv = length(ps)
# Build adjacency_matrix, A_ij, where A_ij = 1 indicates that package j depends on package i.
am = zeros(Int64, nv, nv)
for (k,v) in pkgs_deps
j = findfirst(isequal(k), ps)
for dep in v
i = findfirst(isequal(dep), ps)
if !isnothing(i)
am[i,j] = 1
end
end
end
g = DiGraph(am)
end
pkgs = deps["GraphRecipes"]
pyplot()
g = create_graph(deps["GraphRecipes"], deps)
gp = graphplot(g, names=pkgs, curvature_scalar=0.0, nodeshape=:circle, size=(2800,2800),
method=:stress, arrow=arrow(0.8,0.8))
Wow :-O
@JackDevine Totally fine with it! Great visualizations!