[R] Add transitivity to a matrix?

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Mon Jun 17 19:21:55 CEST 2019

On 17/06/2019 1:19 p.m., Duncan Murdoch wrote:
> Suppose I have a square logical matrix M which I'm thinking of as a
> relation between the row/column numbers.
> I can make it into a symmetric relation (i.e. M[i,j] being TRUE implies
> M[j,i] is TRUE) by the calculation
> M <- M | t(M)
> Is there a simple way to ensure transitivity, i.e. M[i,j] & M[j,k] both
> being TRUE implies M[i,k] is TRUE?
> The operation should only change FALSE or NA values to TRUE values; TRUE
> values should never be changed.

I also want the changes to be minimal; changing everything to TRUE would 
satisfy transitivity, but isn't useful to me.

Duncan Murdoch

More information about the R-help mailing list