bug fix
This commit is contained in:
parent
e953d8aa1f
commit
1922396b71
20
src/SOCgen.c
20
src/SOCgen.c
@ -339,23 +339,25 @@ int find_cycles(int *cycles, int *cyclescnt, int n, const int *children, \
|
||||
* 1 otherwise.
|
||||
*
|
||||
* If there is no cycle, then the graph trivially satisfy this condition.
|
||||
*
|
||||
* If there are k-cycles, then a chord
|
||||
* A) introduces a two-cycle, or
|
||||
* B) introduces a (k-1)-cycle.
|
||||
* So, if there are no two-cycles, then we must only test the cycles of length
|
||||
* k where cyclescnt[k-1] is nonzero.
|
||||
*
|
||||
* Cycles of length two are trivially chordless.
|
||||
* If there is a k-cycle, then a chord implies the existance of an l-cycle
|
||||
* with l < k.
|
||||
***/
|
||||
int gischordless(int n, const int *parents, const int *parentslen, \
|
||||
const int *children, const int *childrenlen, const int *cycles, \
|
||||
const int *cyclescnt, int num_cycles) {
|
||||
if (!num_cycles) return 1;
|
||||
const int hastwocycles = cyclescnt[2];
|
||||
for (int clen=n; clen>2; clen--) {
|
||||
if (!cyclescnt[clen]) continue;
|
||||
if (!hastwocycles && !cyclescnt[clen-1]) continue;
|
||||
// A chord can only exist if there is a cycle of length < clen
|
||||
int shortercycleexists = 0;
|
||||
for (int sclen = 2; sclen < clen; sclen++) {
|
||||
if (cyclescnt[sclen]) {
|
||||
shortercycleexists = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!shortercycleexists) return 1;
|
||||
for (int i=0; i<cyclescnt[clen]; i++) {
|
||||
const int bs = blocksize(n);
|
||||
const int startidx = clen*bs + i*clen; // Cycle starts here
|
||||
|
Loading…
Reference in New Issue
Block a user