How to measure a length of an edge?

When calling edges(g) in Graph.jl , it gives a list. Is there any function that returns the length of and edge in a weighted graph? I know it might seems strange to ask this as we already know the weight (length) of each edge when creating the graph. However, I’d like to know if it;s possible to query in code (not looking the data again)

A weights function should be available for weighted graphs.{AbstractGraph}

To figure out things like this yourself in the future, remember that it’s possible to search in the documentation, and it’s also possible to search in the Julia REPL help.

1 Like

Knowing the weight of a single edge is not necessarily straightforward depending on the type of graph that you use. The built-in function weights(g) returns a (usually sparse) adjacency matrix with all edge weights, so in some situations it would be very wasteful. What are you trying to do exactly?

Hi again,
So there is active discussion on the Graphs.jl repo about these labelling problems, which we hope to address in version 2.0. Feel free to pitch in, for instance using this issue.
About your specific question, note that the built-in induced_subgraph function also returns a translation vector between old and new vertices. Is this the one you are using?