2.4. igraph_average_path_length — Calculates the average geodesic length in a graph.

int igraph_average_path_length(const igraph_t *graph, igraph_real_t *res,
			       igraph_bool_t directed, igraph_bool_t unconn);

Arguments: 

graph:

The graph object.

res:

Pointer to a real number, this will contain the result.

directed:

Boolean, whether to consider directed paths. Ignored for undirected graphs.

unconn:

What to do if the graph is not connected. If TRUE the average of thr geodesics within the components will be returned, otherwise the number of vertices is used for the length of non-existing geodesics. (The rationale behind this is that this is always longer than the longest possible geodesic in a graph.)

Returns: 

Error code: IGRAPH_ENOMEM, not enough memory for data structures

Time complexity: O(|V||E|), the number of vertices times the number of edges.