X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/ef0175024063536689906e706f83ee9a12af98e3..9515e8a7f83cbb920491ceaef03f8e0fe0ce8108:/lib/bitsetv.c diff --git a/lib/bitsetv.c b/lib/bitsetv.c index b6eb77e8..be4bfa7d 100644 --- a/lib/bitsetv.c +++ b/lib/bitsetv.c @@ -111,6 +111,37 @@ bitsetv_ones (bsetv) } +/* Given a vector BSETV of N bitsets of size N, modify its contents to + be the transitive closure of what was given. */ +void +bitsetv_transitive_closure (bsetv) + bitset *bsetv; +{ + unsigned int i; + unsigned int j; + + for (i = 0; bsetv[i]; i++) + for (j = 0; bsetv[j]; j++) + if (bitset_test (bsetv[j], i)) + bitset_or (bsetv[j], bsetv[j], bsetv[i]); +} + + +/* Given a vector BSETV of N bitsets of size N, modify its contents to + be the reflexive transitive closure of what was given. This is + the same as transitive closure but with all bits on the diagonal + of the bit matrix set. */ +void +bitsetv_reflexive_transitive_closure (bitsetv bsetv) +{ + int i; + + bitsetv_transitive_closure (bsetv); + for (i = 0; bsetv[i]; i++) + bitset_set (bsetv[i], i); +} + + /* Dump the contents of a bitset vector BSETV with N_VECS elements to FILE. */ void