Add --all option

This commit is contained in:
Ämin Baumeler 2024-11-15 11:41:45 +01:00
parent 08823b2770
commit 19119a5adf

View File

@ -461,6 +461,7 @@ int main(int argc, char *argv[]) {
int RANDOM = 0;
int GRAPHVIZ = 0;
int UNKOPTION = 0;
int ALL = 0;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-n") == 0 && i+1 < argc) {
n = atoi(argv[i+1]);
@ -476,6 +477,8 @@ int main(int argc, char *argv[]) {
NOSOURCE = 1;
} else if (strcmp(argv[i], "--graphviz") == 0) {
GRAPHVIZ = 1;
} else if (strcmp(argv[i], "--all") == 0) {
ALL = 1;
} else {
UNKOPTION = 1;
break;
@ -486,6 +489,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, " -n <order> Generate SOCs with `order' connected nodes\n");
fprintf(stderr, " -r <num> Pick directed graphs at random, and exit after having found `num' SOCs\n");
fprintf(stderr, " --graphviz Output SOCs in Graphviz format, arcs of common parents are highlighted\n");
fprintf(stderr, " --all Allow for disconnected SOCs and disable the degree-order filter (see below)\n");
fprintf(stderr, "\n");
fprintf(stderr, "[FILTER] Consider only simple directed graphs ...\n");
fprintf(stderr, " -c ... that are cyclic (i.e., not DAGs)\n");
@ -493,7 +497,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, " --no-source ... without source nodes (also this logically implies -c)\n");
fprintf(stderr, "\n");
fprintf(stderr, "This program prints the found SOCs as adjacency matrices to stdout, unless --graphviz has been specified.\n");
fprintf(stderr, "To exclude (some) of the isomorphic SOCs, it uses a degree-order filter.\n");
fprintf(stderr, "To exclude (some) of the isomorphic SOCs, it uses a degree-order filter, unless --all is specified.\n");
return -1;
}
// EO Parse command-line arguments
@ -583,10 +587,10 @@ int main(int argc, char *argv[]) {
// Check whether this graph is canonical or not; continue if graph has not
// proper ordering of degress (there is an isomorphic graphs to this one
// that has been or will be checked)
if (!isdegreeordered(n, parents, parentslen, children, childrenlen))
if (!ALL && !isdegreeordered(n, parents, parentslen, children, childrenlen))
continue;
// Ignore graphs that are not connected
if (!isconnected(n, parents, parentslen, children, childrenlen))
if (!ALL && !isconnected(n, parents, parentslen, children, childrenlen))
continue;
// Find cycles
const int num_cycles = find_cycles(cycles, cyclescnt, n, children, \