shortest_path_lengths: Shortest Path Lengths (Unweighted & Undirected)

Description Usage Arguments Value Examples

Description

Computes shortest path lengths for an unweighted, undirected graph. For graphs with these properties, this function is much faster than the function distances in the igraph package.

Usage

1
shortest_path_lengths(graph, nodes = V(graph))

Arguments

graph

an igraph object.

nodes

a subset of the nodes of the graph to find the distances between. defaults to all nodes (all pairs shortest path lengths).

Value

returns a symmetric "matrix" object where the ijth entry is the shortest path distance from v_i to v_j, d(v_i,v_j), for all v_i,v_j \in V.

Examples

1
2
3
4
sp <- shortest_path_lengths(dolphins);
sp[1:10,1:10];
## Check against igraphs distance function
all(sp == igraph::distances(dolphins, algorithm = "unweighted"));

barrpet/gclust documentation built on May 11, 2019, 6:23 p.m.