16.2. igraph_reciprocity — Calculates the reciprocity of a directed graph.

int igraph_reciprocity(const igraph_t *graph, igraph_real_t *res, 
		       igraph_bool_t ignore_loops);

A vertex pair (A, B) is said to be reciprocal if there are edges between them in both directions. The reciprocity of a directed graph is the proportion of all possible (A, B) pairs which are reciprocal, provided there is at least one edge between A and B. The reciprocity of an empty graph is undefined (results in an error code). Undirected graphs always have a reciprocity of 1.0 unless they are empty.

Arguments: 

graph:

The graph object.

res:

Pointer to an igraph_real_t which will contain the result.

ignore_loops:

Whether to ignore loop edges.

Returns: 

Error code: IGRAPH_EINVAL: graph has no edges IGRAPH_ENOMEM: not enough memory for temporary data.

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