Write a function to find the reachability matrix for a


If A is an n x n adjacency matrix for a directed graph, then the entry in the ith row and jth column of A k is equal to the number of paths of length k from the ith vertex to the jth vertex in this digraph.

The reachability matrix R of a digraph is the n x n matrix defined by

R = 1 + A + A2 +.....+ An-1

where I is the n x n identity matrix having ones on the diagonal (from upper left corner to lower right corner) and zeros oft In the digraph, there is a path from vertex i to vertex j if and only if the entry in row i and column j of R is nonzero.

Write a function to find the reachability matrix for a directed graph.

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Write a function to find the reachability matrix for a
Reference No:- TGS02589678

Expected delivery within 24 Hours