Added "night" option to SOCgraphviz, fixed typos

This commit is contained in:
Ämin Baumeler 2023-09-14 14:24:31 +02:00
parent b6cdd049bf
commit 6916498836
3 changed files with 55 additions and 10 deletions

View File

@ -32,7 +32,7 @@ To display help and exit, run the respective program without command-line argume
### SOCgen
```
$ ./SOCgen
Usage: ./SOCgen -n <order> [-r <num>] [--grpahviz] [FILTER ...]
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
@ -42,7 +42,7 @@ Usage: ./SOCgen -n <order> [-r <num>] [--grpahviz] [FILTER ...]
--no-sink ... without sink nodes (this logically implies -c)
--no-source ... without source nodes (also this logically implies -c)
This program prints the found SOCs as adjacency matrices to stdout, unless --grpahviz has been specified.
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.
```
@ -66,7 +66,7 @@ This program verifies the admissibility of simple directed graphs.
### SOCgraphviz
```
$ ./SOCgraphviz
Usage: ./SOCgraphviz <filename>
Usage: ./SOCgraphviz <filename> [night]
<filename> File name with adjacency matrices of simple directed graphs
[FILE FORMAT]
@ -75,6 +75,7 @@ Usage: ./SOCgraphviz <filename>
The file `filename' may contain graphs with different order (number of vertices)
This program translates to adjacency matrices into the Graphviz format, and prints them to stdout.
Try the optional argument ``night'' for star-constallation-like output.
```
### removeiso.py

View File

@ -482,7 +482,7 @@ int main(int argc, char *argv[]) {
}
}
if (UNKOPTION || n <= 1) {
fprintf(stderr, "Usage: %s -n <order> [-r <num>] [--grpahviz] [FILTER ...]\n", argv[0]);
fprintf(stderr, "Usage: %s -n <order> [-r <num>] [--graphviz] [FILTER ...]\n", argv[0]);
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");
@ -492,7 +492,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, " --no-sink ... without sink nodes (this logically implies -c)\n");
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 --grpahviz has been specified.\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");
return -1;
}
@ -556,7 +556,7 @@ int main(int argc, char *argv[]) {
padlen+3, SOCrate, padlen, ETC);
fflush(stderr);
}
// Convert graph index `grpahnumber' to the lists parents, children,
// Convert graph index `graphnumber' to the lists parents, children,
// parentslen, childrenlen
graphnrtolists(n, graphnumber, parents, parentslen, children, childrenlen);
// Increase checked counter and prepare for next iteration

View File

@ -4,11 +4,52 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
// Global configuration for the "night" mode
const float maxSize = 0.1;
const float minSize = 0.001;
const char *starColors[] = {
"white",
"lightgray",
"darkslategray",
"lightyellow",
"purple",
"cyan",
"silver",
"khaki", "khaki1", "khaki2", "khaki3", "khaki4",
"gold", "gold1", "gold2", "gold3", "gold4",
"darkgoldenrod", "darkgoldenrod1", "darkgoldenrod2", "darkgoldenrod3", "darkgoldenrod4",
"darkorange", "darkorange1", "darkorange2", "darkorange3", "darkorange4",
"coral", "coral1", "coral2", "coral3", "coral4",
"chocolate", "chocolate1", "chocolate2", "chocolate3", "chocolate4",
"antiquewhite", "antiquewhite1", "antiquewhite2", "antiquewhite3", "antiquewhite4",
"azure", "azure1", "azure2", "azure3", "azure4",
"bisque", "bisque1", "bisque2", "bisque3", "bisque4",
"seashell", "seashell1", "seashell2", "seashell3", "seashell4",
"lightyellow", "lightyellow1", "lightyellow2", "lightyellow3", "lightyellow4",
"lightpink", "lightpink1", "lightpink2", "lightpink3", "lightpink4",
"burlywood", "burlywood1", "burlywood2", "burlywood3", "burlywood4",
"lavenderblush", "lavenderblush1", "lavenderblush2", "lavenderblush3", "lavenderblush4",
};
const size_t numColors = sizeof(starColors) / sizeof(starColors[0]);
void printgraphhead(char *filename, const int line, const int NIGHT) {
printf("strict digraph \"File_%s_line_%d\" {", filename, line);
if (NIGHT) {
double rsize = minSize + (((double)rand() / RAND_MAX) * (maxSize - minSize));
int rcolor = rand() % numColors;
printf(" bgcolor=\"black\";");
printf(" node [shape=point, color=%s, style=filled, width=%lf, height=%lf];", starColors[rcolor], rsize, rsize);
printf(" edge [color=lightgray, penwidth=0.5];");
}
}
int main(int argc, char *argv[]) {
// Parse command-line arguments
if (argc != 2) {
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
if (argc != 2 && (argc != 3 || strcmp(argv[2], "night") != 0)) {
fprintf(stderr, "Usage: %s <filename> [night]\n", argv[0]);
fprintf(stderr, " <filename> File name with adjacency matrices of simple directed graphs\n");
fprintf(stderr, "\n");
fprintf(stderr, "[FILE FORMAT]\n");
@ -17,8 +58,11 @@ int main(int argc, char *argv[]) {
fprintf(stderr, " The file `filename' may contain graphs with different order (number of vertices)\n");
fprintf(stderr, "\n");
fprintf(stderr, "This program translates to adjacency matrices into the Graphviz format, and prints them to stdout.\n");
fprintf(stderr, "Try the optional argument ``night'' for star-constallation-like output.\n");
return -1;
}
const int NIGHT = argc - 2;
srand(time(NULL));
// Open file
FILE *fp;
@ -33,14 +77,14 @@ int main(int argc, char *argv[]) {
int n = -1;
int row = 0;
int col = 0;
printf("strict digraph \"File_%s_line_%d\" {", argv[1], line);
printgraphhead(argv[1], line, NIGHT);
while (!feof(fp)) {
char ch = fgetc(fp);
switch (ch) {
case '{':
if (row == 0 && col == 0 && headprinted == 0) {
headprinted = 1;
printf("strict digraph \"File_%s_line_%d\" {", argv[1], line);
printgraphhead(argv[1], line, NIGHT);
}
break;
case '0':