#include <stdlib.h>
#include <stdio.h>
void harborth_graph() {
/* Data by:
EBERHARD H.-A. GERBRACHT
MINIMAL POLYNOMIALS FOR THE COORDINATES OF THE HARBORTH GRAPH
24 Jan 2007
*/
const size_t N = 16;
double V[N][2] = {
{ 0.0, 0.0 },
{ 0.992685948824186, 0.120725337054926 },
{ 0.992685948824186*2, 0.0 },
{ 0.809996600722107, 2.760161754567202 },
{ 0.209102417540010, 1.960833173433061 },
{ -0.061398137844065, 0.998113354619244 },
{ -0.838419516770942, 1.627587561152422 },
{ -0.995049481192288, 3.621444891616507 },
{ 0,0 }, // The I Vertex
{ -0.995049481192288, 0.639930204451542 },
};
V[10][0] = V[2][0] * 2/ 3 + V[3][0] / 3;
V[10][1] = V[2][1] * 2 / 3 + V[3][1] / 3;
V[11][0] = V[2][0] / 3 + V[3][0] *2/ 3;
V[11][1] = V[2][1] / 3 + V[3][1] *2/ 3;
V[12][0] = V[1][0] / 2 + V[4][0] / 2;
V[12][1] = V[1][1] / 2 + V[4][1] / 2;
V[13][0] = V[3][0] / 2 + V[6][0] / 2;
V[13][1] = V[3][1] / 2 + V[6][1] / 2;
V[14][0] = V[3][0] / 2 + V[7][0] / 2;
V[14][1] = V[3][1] / 2 + V[7][1] / 2;
V[15][0] = V[6][0] / 2 + V[7][0] / 2;
V[15][1] = V[6][1] / 2 + V[7][1] / 2;
const size_t M = 27;
int E[M][2] = {
{ 0, 1 }, { 1, 2 }, { 2, 10 }, { 10, 11 }, { 11, 3 }, { 3, 4 }, { 4, 11 }, { 11, 12 }, { 4, 12 },
{ 12, 1 }, { 12, 10 }, { 2, 10 }, { 1, 10 }, { 4, 5 }, { 0, 5 }, { 5, 6 }, { 5, 9 }, {9,6},
{6,13}, {13,3}, {3,14}, {14,7}, {7,15}, {15,6}, {13,14}, {14,15}, {15,13}
};
const double SX = 700;
const double SY = 800;
const double SS = 100;
FILE * fo = fopen("c:\\temp\\harborth_graph.svg", "w");
fprintf(fo,
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
"<svg\n"
"xmlns:svg=\"http://www.w3.org/2000/svg\"\n"
"xmlns=\"http://www.w3.org/2000/svg\"\n"
"version=\"1.0\"\n"
"width=\"%g\"\n" "height=\"%g\"\n"
"id=\"harborth_grap\">\n"
, SX, SY
);
size_t i,v;
fprintf(fo, "<g id=\"edges\" style=\"stroke:#000000;stroke-width:2;\">\n");
for (v = 0; v < 4; ++v) {
double sx = v == 0 || v == 1 ? 1 : -1;
double sy = v == 0 || v == 2 ? 1 : -1;
for (i = 0; i < M; ++i)
fprintf(fo, "<line x1=\"%5.1lf\" y1=\"%5.1lf\" x2=\"%5.1lf\" y2=\"%5.1lf\"/>\n"
, (V[E[i][0]][0]+1)*sx * SS + SX / 2, SY / 2 - V[E[i][0]][1] *sy * SS
, (V[E[i][1]][0]+1)*sx * SS + SX / 2, SY / 2 - V[E[i][1]][1] *sy * SS
);
}
fprintf(fo, "</g>\n");
fprintf(fo, "<g id=\"nodes\" style=\"stroke:none;fill:#000000\">\n");
for (v = 0; v < 4; ++v) {
double sx = v == 0 || v == 1 ? 1 : -1;
double sy = v == 0 || v == 2 ? 1 : -1;
for (i = 0; i < N; ++i) {
if (i == 8 || ((i==0 || i==2) && (v==1 || v==3)) ) continue;
if ((i == 7 || i==9) && (v==2 || v==3)) continue; // remove duplicates
fprintf(fo, "<circle cx=\"%5.1lf\" cy=\"%5.1lf\" r=\"%5.1lf\"/>"
, (V[i][0]+1)*sx * SS + SX / 2, SY / 2 - V[i][1] *sy * SS
, 6.0
);
}
}
fprintf(fo, "</g>\n");
fprintf(fo, "</svg>\n");
fclose(fo);
}