Compare commits
2 Commits
19119a5adf
...
06690e4982
Author | SHA1 | Date | |
---|---|---|---|
06690e4982 | |||
a8b52a581f |
@ -36,6 +36,8 @@ Usage: ./SOCgen -n <order> [-r <num>] [--graphviz] [FILTER ...]
|
||||
-n <order> Generate SOCs with `order' connected nodes
|
||||
-r <num> Pick directed graphs at random, and exit after having found `num' SOCs
|
||||
--graphviz Output SOCs in Graphviz format, arcs of common parents are highlighted
|
||||
--vector Output SOCs adjacency vectors in the order (0<-1, 0<-2, ..., 1<-0, 1<-2, ...)
|
||||
--all Allow for disconnected SOCs and disable the degree-order filter (see below)
|
||||
|
||||
[FILTER] Consider only simple directed graphs ...
|
||||
-c ... that are cyclic (i.e., not DAGs)
|
||||
@ -43,7 +45,7 @@ Usage: ./SOCgen -n <order> [-r <num>] [--graphviz] [FILTER ...]
|
||||
--no-source ... without source nodes (also this logically implies -c)
|
||||
|
||||
This program prints the found SOCs as adjacency matrices to stdout, unless --graphviz has been specified.
|
||||
To exclude (some) of the isomorphic SOCs, it uses a degree-order filter.
|
||||
To exclude (some) of the isomorphic SOCs, it uses a degree-order filter, unless --all is specified.
|
||||
```
|
||||
|
||||
### SOCadmissible
|
||||
|
30
src/SOCgen.c
30
src/SOCgen.c
@ -32,6 +32,30 @@ void dumpgraph(int n, const int *children, const int *childrenlen) {
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
/***
|
||||
* Print the graph's adjacency vector.
|
||||
* The entries are (0<-1, 0<-2, ...1, 1<-0, 1<-2, ...)
|
||||
***/
|
||||
void dumpgraphvector(int n, const int *parents, const int *parentslen) {
|
||||
int edge = 0;
|
||||
for (int a = 0; a < n; a++) {
|
||||
for (int b = 0; b < n; b++) {
|
||||
if (a==b) continue;
|
||||
edge = 0;
|
||||
for (int i = 0; i < parentslen[a] && !edge; i++) {
|
||||
const int v = parents[a*n+i];
|
||||
if (b==v) {
|
||||
printf("1");
|
||||
edge = 1;
|
||||
}
|
||||
}
|
||||
if (!edge)
|
||||
printf("0");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/***
|
||||
* Print the graph as graphviz command
|
||||
***/
|
||||
@ -460,6 +484,7 @@ int main(int argc, char *argv[]) {
|
||||
int NOSOURCE = 0;
|
||||
int RANDOM = 0;
|
||||
int GRAPHVIZ = 0;
|
||||
int VECTOR = 0;
|
||||
int UNKOPTION = 0;
|
||||
int ALL = 0;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
@ -479,6 +504,8 @@ int main(int argc, char *argv[]) {
|
||||
GRAPHVIZ = 1;
|
||||
} else if (strcmp(argv[i], "--all") == 0) {
|
||||
ALL = 1;
|
||||
} else if (strcmp(argv[i], "--vector") == 0) {
|
||||
VECTOR = 1;
|
||||
} else {
|
||||
UNKOPTION = 1;
|
||||
break;
|
||||
@ -489,6 +516,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, " --vector Output SOCs adjacency vectors in the order (0<-1, 0<-2, ..., 1<-0, 1<-2, ...)\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");
|
||||
@ -605,6 +633,8 @@ int main(int argc, char *argv[]) {
|
||||
len++;
|
||||
if (GRAPHVIZ)
|
||||
dumpgv(n, graphnumber, children, childrenlen);
|
||||
else if (VECTOR)
|
||||
dumpgraphvector(n, parents, parentslen);
|
||||
else
|
||||
dumpgraph(n, children, childrenlen);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user