Coder Social home page Coder Social logo

degree of loops about graphs.jl HOT 1 OPEN

etiennedeg avatar etiennedeg commented on July 17, 2024
degree of loops

from graphs.jl.

Comments (1)

simonschoelly avatar simonschoelly commented on July 17, 2024 2

I feel like I have seen this question before, but maybe it was about something else.

I am not sure if this is a bug, or a deliberate choice to just return the length of the adjacency list - as this is computationally very efficient. It also matches what the documentation states, namely

for undirected graphs, it equals the connected edges.

But as probably every textbook defines this differently we should probably change this eventually.

I would propose, that we would add the following functions

num_neighbors(g, v)  # return the number of connected neighbors (inclusive itself in case of a self-loop
num_edges(g, v)  # number of connected edges

Maybe of the difficult to wrote num_neighbors we could also write num_vertices(g, v) - not sure about that though. num_edges might also be helpful, if we ever implement multigraphs.

Of course we also would then create the directed versions of these functions for directed graphs. Btw, I am not sure, how much degree makes sense for directed graphs - it is the indegree plus the outdegree, so

julia> gd = SimpleDiGraph([Edge(1, 1)]);
julia> degree(gd, 1)
2

so in this case this seems correct.

I am not completely sure how we should proceed about degree - maybe it would make sense to deprecate the degree functions for a while altogether, and then later reintroduce them with a changed behavior?

from graphs.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.