Skip to content

Handling of edge weights in metrics.avg.pathlength #287

@bockthom

Description

@bockthom

Description

@Comelp has figured out that metrics.avg.pathlength can return an avg. path length that is way longer than the number of edges in the network, which sounds weird.

After quickly debugging this, I noticed that this is due to edge weights in simplified networks. We might need to think whether we provide the option (i.e., add a parameter) to ignore edge weights when calculating avg. path length. But if so, I am not sure which one should be the default option.

Steps to Reproduce or Minimal Working Example (MWE)

igraph's mean_distance function first computes the shortest paths, and to get the length of these paths, it sums the weights of the path. For example, if the shortest path consists of two edges whose weights are 5 and 7, the shortest path length is not 2, but 12. The weights in our network originate from network simplification and just denote the number of unsimplified edges that have been present between a pair of vertices prior to network simplification. I am not sure whether these weights are meaningful to us when computing avg path length or not. Your opinions are welcome here.

Suggestion

We could add parameter weight = NA to igraph::mean_distance in order to ignore edge weights. To do so, I would add a new parameter ignore.weights to metrics.avg.pathlength - but I am unsure about the default value.

metrics.avg.pathlength = function(network, directed = TRUE, unconnected = TRUE) {
avg.pathlength = igraph::mean_distance(network, directed = directed, unconnected = unconnected)
return(c(avg.pathlength = avg.pathlength))

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions