sbromberger/LightGraphs.jl

[FR] add core functions

BeastyBlacksmith opened this issue · 7 comments

It would be nice to have a degree property that has a more performant implementation than
degree(v) = length(neighbors(graph, vertex))

The current implementation is O(1) in time and memory. What are you suggesting could be more performant?

Here's a demonstration:

julia> g = star_graph(100_000_000)
{100000000, 99999999} undirected simple Int64 graph

julia> @btime degree(g, 1)
  16.834 ns (1 allocation: 16 bytes)
99999999

julia> h = Graph(1)
{1, 0} undirected simple Int64 graph

julia> @btime degree(h, 1)
  14.319 ns (0 allocations: 0 bytes)
0

aha, I just missed that function from the documentation.
I'll make a PR

Thats true, but I expected it to find it among the vertex properties and in hindsight it was a bit silly to stop searching when I didn't find it there, but others might do the same

I think a better PR would be to ensure "Core Functions" is a sidebar item. I'm not generally inclined to have multiple references to functions in the documentation. That gets confusing and pollutes search results.

Also a good idea. Changed that