-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HELP] how to get edges of a vertex? #151
Comments
Hi @lucasmsoares96! Could you be more specific as to what you want to do exactly? What kind of graph are you working with? |
Hi @gdalle! Thanks for the tip. I solved it as follows:
|
@lucasmsoares96 this works but it highly inefficient, because you have to enumerate every single edge in the whole graph when handling a single vertex. Can I ask what the application is? In particular, do you need to recover edge weights? |
Cause I think you could do something better by looking at the implementation of using Graphs, SimpleWeightedGraphs
function outedges(g::AbstractSimpleWeightedGraph, i::Integer)
return (SimpleWeightedEdge(i, j, g.weights[j, i]) for j in outneighbors(g, i))
end The inversion between |
Currently, the only function in the API that return edges of a given graph is |
I'm just doing a reconnaissance of the Julia language. Your solution solves the problem more efficiently. I solved it by going through the list of edges because it made more sense for me to actually return the edge than to return a copy. |
No worries! I'm closing the issue if that's alright, feel free to reach out if you need more help |
I need to get all edges that come out of a given vertex. The
edges(g)
function returns a list of edges for the entire graph. Is there any way to get only the edges of a vertex? For exampleedges(g,1)
to get all edges from vertex 1.The text was updated successfully, but these errors were encountered: