JuliaGraphs / GraphPlot.jl

Graph visualization for Julia.
http://JuliaGraphs.github.io/GraphPlot.jl/
Other
200 stars 62 forks source link

Documentation uses num_vertices but num_vertices is undefined #168

Closed BrettKnoss closed 2 years ago

BrettKnoss commented 2 years ago

The documentation for GraphPlots has:

g=graphfamous("karate")
nodelabels=[1:num_vertices(g)]
gplot(g,nodelabels=nodelabels)

but num_vertices and Graphs.num_vertices are undefined. Is this from a different version of Graphs.jl ?

vertices(g) outputs BaseOneTo(34) and nv(g) outputs 34

but gplot(g,nodelabel=[1:34]) outputs:


error(::String)@error.jl:33
var"#gplot#14"(::Vector{UnitRange{Int64}}, ::ColorTypes.RGB{FixedPointNumbers.N0f8}, ::Float64, ::Float64, ::Float64, ::Float64, ::Vector{Any}, ::ColorTypes.RGB{FixedPointNumbers.N0f8}, ::Float64, ::Float64, ::ColorTypes.RGB{FixedPointNumbers.N0f8}, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::Float64, ::ColorTypes.RGB{FixedPointNumbers.N0f8}, ::Nothing, ::Float64, ::Float64, ::Float64, ::String, ::Float64, ::typeof(GraphPlot.gplot), ::Graphs.SimpleGraphs.SimpleGraph{Int64}, ::Vector{Float64}, ::Vector{Float64})@plot.jl:119
#gplot#20@plot.jl:229[inlined]
top-level scope@[Local: 1](http://localhost:1234/edit?id=fbd1b6d8-da52-11ec-1970-c3bff3c36c49#)[inlined]

I can see that the number of nodes should be correct, but I'm not sure where the issue is.

etiennedeg commented 2 years ago

num_vertices was the old method, now replaced by nv. I don't see exactly where you see this example in the documentation, but there is effectively some occurences of num_vertices and num_edges in the docs. Passing [1:34] for nodelabel should not work because this is a vector of ranges, you should just pass 1:34 or use gplot(g,nodelabel=vertices(g))

etiennedeg commented 2 years ago

Tell me if you see another place where you see num_vertices, since I did not found the exact occurrence of your documentation.

Stfort52 commented 2 years ago

hello @etiennedeg, https://juliagraphs.org/GraphPlot.jl/ still uses num_vertices and other outdated functions. If this is an issue not for GraphPlot but for juliagraph.github.io, I'm sorry for pointing this out in a wrong place.