Comments (1)
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)
- Question regarding `non_backtracking_matrix` function's return type HOT 1
- Tests failing on nightly
- Fix source of randomness in doctests HOT 3
- Functions for Edge Adjacency HOT 1
- [BUG] `StackOverflowError` in `Graphs.Experimental.has_isomorph` HOT 5
- Inconsistent dependency on ArnoldiMethod HOT 8
- [BUG] edges(::SimpleGraph) is broken in 1.10.0 HOT 2
- [BUG] `steiner_tree` fails if only one terminal vertex is passed HOT 1
- [BUG] `merge_vertices` returns an undirected graph, even if the input is directed.
- Define `rem_edge!(::AbstractGraph, ::Pair)` HOT 1
- `SimpleGraph(::Base.OneTo)` HOT 1
- Incorrect documentation for `dfs_tree`. HOT 2
- dorogovtsev_mendes graph generator is running in O(n^2) HOT 1
- Add tests on release candidate when it comes out
- [OPTIM] perm_greedy_color (and thus all coloring algorithms) is running in O(n^2) instead of O(n) HOT 1
- [BUG] Extra vertices in Steiner tree HOT 1
- [FR] Construct a graph corresponding to a binary relation HOT 4
- [FR] a function to efficiently check whether a graph is acyclic HOT 1
- Hope to implement of infomap HOT 1
- [BUG] Compatibility issue when used alongside GraphPlot HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphs.jl.