forked from cseed/knotkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
planar_diagram.cpp
55 lines (49 loc) · 1.18 KB
/
planar_diagram.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <knotkit.h>
planar_diagram::planar_diagram (const std::string &name_, unsigned n_crossings, const int crossings_ar[][4])
: name(name_),
crossings(n_crossings)
{
for (unsigned i = 1; i <= n_crossings; i ++)
{
for (unsigned j = 1; j <= 4; j ++)
crossings[i].append (crossings_ar[i - 1][j - 1]);
}
}
planar_diagram::planar_diagram (const knot_diagram &kd)
: name(kd.name),
crossings(kd.planar_diagram_crossings ())
{
}
void
planar_diagram::show_knottheory () const
{
printf ("PD[");
for (unsigned i = 1; i <= crossings.size (); i ++)
{
if (i > 1)
printf (",");
printf ("X[%d,%d,%d,%d]",
crossings[i][1],
crossings[i][2],
crossings[i][3],
crossings[i][4]);
}
printf ("]");
}
void
planar_diagram::display_self () const
{
printf ("planar_diagram %s ", name.c_str ());
for (unsigned i = 1; i <= crossings.size (); i ++)
{
int i1 = crossings[i][1],
i2 = crossings[i][2],
i3 = crossings[i][3],
i4 = crossings[i][4];
if (i1 >= 10 || i2 >= 10 || i3 >= 10 || i4 >= 10)
printf ("X_%d,%d,%d,%d", i1, i2, i3, i4);
else
printf ("X_%d%d%d%d", i1, i2, i3, i4);
}
printf ("\n");
}