[Numpy-discussion] matrix multiply

Alan G Isaac aisaac at american.edu
Mon Apr 7 00:38:39 EDT 2008


On Sun, 6 Apr 2008, Charles R Harris apparently wrote:
> You mean as edges in a directed graph? 

Yes.

Naturally a boolean matrix is not the most compact
representation of a directed graph, especially a
sparse one.  However it can be convenient.

If B is a boolean matrix such that Bij=1 if there is
and edge from i to j, then B**2 has unit entries where
there is a path of length 2 from i to j.  The transitive
closure is similarly easy to represent (as a matrix power).

Cheers,
Alan Isaac






More information about the NumPy-Discussion mailing list