shortest_distances: Calculate shortest distances of unweighted graph

Description Usage Arguments Details Value

View source: R/graph.R

Description

Calculate all pairs of shortest distances of unweighted graph

Usage

1
2
3
4
shortest_distances(
  adj_matrix,
  source_nodes = rep_len(TRUE, dim(adj_matrix)[1])
)

Arguments

adj_matrix

Logical adjacency matrix of given unweighted graph

source_nodes

Logical vector to indicate the source nodes that need to calculate the shortest distances

Details

This function calculates all pairs of shortest distances of unweighted graph by using breadth-first-search (BFS) algorithm.

Value

This function will return the shortest distance matrix, where the element [i, j] is the shortest distance between node i and j. Value Inf means unreachable. If source_nodes[i] equals FALSE, the shortest distance from i to other nodes will not be calculated and the row i will be all Inf.


wulingyun/BlockSim documentation built on Dec. 4, 2019, 1:54 a.m.