Mercurial > defical
annotate defical-c/src/graphmagic.cpp @ 1:758381a85d76 default tip
Incorrect printf format.
author | Edho Prima Arief <me@myconan.net> |
---|---|
date | Mon, 28 Jun 2010 14:52:19 +0700 |
parents | ebed2bd0d300 |
children |
rev | line source |
---|---|
0
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
1 #include "graphmagic.h" |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
2 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
3 semtd::semtd(){} |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
4 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
5 semtd::semtd(uint32_t graphType,uint32_t NumVer, uint32_t numDef) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
6 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
7 if(NumVer>3){ |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
8 this->NumVer=NumVer; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
9 this->numDef=numDef; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
10 this->graphType=graphType; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
11 this->TotalVer=NumVer+numDef; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
12 this->numEdges=0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
13 this->isSureFail=false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
14 this->edgeLabelAbsoluteMax=this->TotalVer*2-1; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
15 //initialize graph array |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
16 //this->theGraph.resize(this->NumVer+1,vector<bool>(this->NumVer+1,false)); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
17 for (int i=0; i<1000;i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
18 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
19 for (int j=0;j<1000;j++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
20 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
21 this->theGraph[i][j]=false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
22 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
23 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
24 draw(this->graphType,1,this->NumVer); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
25 resetLabels(0); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
26 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
27 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
28 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
29 void semtd::draw(uint32_t drawType,uint32_t start,uint32_t end) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
30 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
31 switch(drawType) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
32 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
33 case 0: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
34 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
35 for (uint32_t i=start;i<end;i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
36 connectVertices(i,i+1); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
37 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
38 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
39 case 1: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
40 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
41 draw(0,start,end); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
42 connectVertices(start,end); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
43 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
44 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
45 case 3: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
46 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
47 draw(1,start+1,end); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
48 draw(2,start+1,end,start); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
49 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
50 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
51 case 4: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
52 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
53 draw(0,start+1,end); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
54 draw(2,start+1,end,start); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
55 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
56 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
57 case 5: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
58 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
59 draw(4,start+1,end); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
60 draw(2,start+2,end,start); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
61 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
62 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
63 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
64 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
65 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
66 void semtd::draw(uint32_t drawType,uint32_t start,uint32_t end, uint32_t extra) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
67 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
68 switch(drawType) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
69 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
70 case 2: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
71 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
72 for (uint32_t i=start;i<=end;i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
73 connectVertices(i,extra); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
74 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
75 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
76 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
77 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
78 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
79 inline void semtd::connectVertices(uint32_t a,uint32_t b) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
80 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
81 if(!this->theGraph[a][b]) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
82 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
83 this->theGraph[a][b]=this->theGraph[b][a]=true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
84 this->numEdges++; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
85 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
86 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
87 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
88 void semtd::resetLabels(uint32_t mode) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
89 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
90 if(mode==0) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
91 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
92 this->VerLabels.clear(); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
93 this->VerLabels.resize(this->NumVer+1,0); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
94 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
95 this->edgeLabels.clear(); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
96 this->edgeLabels.resize(NumVer+1,vector<uint32_t>(NumVer+1,0)); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
97 this->isQuickMode=false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
98 this->scoreCache=-1; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
99 //uint32_t *edgeLabelsUsedPtr; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
100 //edgeLabelsUsedPtr=(uint32_t*)malloc(this->edgeLabelAbsoluteMax+1*sizeof(uint32_t)); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
101 this->edgeLabelsUsed.clear(); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
102 this->edgeLabelsUsed.resize(this->edgeLabelAbsoluteMax+1,0); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
103 this->edgeLabelMax=0;this->edgeLabelMin=this->edgeLabelAbsoluteMax; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
104 refreshEdgeLabelsMinMax(); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
105 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
106 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
107 void semtd::refreshEdgeLabelsMinMax() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
108 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
109 uint32_t i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
110 for (i = 1; i <= this->edgeLabelAbsoluteMax; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
111 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
112 if (this->edgeLabelsUsed[i] > 0) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
113 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
114 this->edgeLabelMin = i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
115 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
116 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
117 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
118 for (int32_t x = this->edgeLabelAbsoluteMax; x >= 0; x--) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
119 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
120 if (this->edgeLabelsUsed[x] > 0) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
121 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
122 this->edgeLabelMax = x; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
123 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
124 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
125 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
126 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
127 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
128 inline uint32_t semtd::edgeLabelRange() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
129 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
130 return this->edgeLabelMax-this->edgeLabelMin+1; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
131 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
132 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
133 void semtd::setEdgeLabels(uint32_t verPos) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
134 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
135 uint32_t newLabel,i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
136 for (i = 1; i <= this->NumVer; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
137 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
138 if (this->VerLabels[i] > 0 && this->theGraph[verPos][i] && i != verPos) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
139 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
140 newLabel = this->VerLabels[verPos] + this->VerLabels[i]; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
141 this->edgeLabels[i][verPos] = this->edgeLabels[i][verPos] = newLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
142 this->edgeLabelsUsed[newLabel]++; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
143 if (this->edgeLabelsUsed[newLabel] != 1) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
144 this->isSureFail = true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
145 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
146 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
147 refreshEdgeLabelsMinMax(); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
148 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
149 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
150 void semtd::removeEdgeLabels(uint32_t verPos) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
151 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
152 uint32_t i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
153 for (i = 1; i <= this->NumVer; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
154 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
155 if (this->VerLabels[i] > 0 && this->theGraph[verPos][i] && i != verPos) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
156 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
157 int oldLabel = this->edgeLabels[i][verPos]; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
158 this->edgeLabelsUsed[oldLabel]--; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
159 this->edgeLabels[i][verPos] = this->edgeLabels[verPos][i] = 0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
160 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
161 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
162 refreshEdgeLabelsMinMax(); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
163 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
164 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
165 void semtd::SetVerLabel(uint32_t verPos,uint32_t verLabel) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
166 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
167 if (this->VerLabels[verPos] > 0) { RemoveVerLabel(verPos); } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
168 this->VerLabels[verPos] = verLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
169 setEdgeLabels(verPos); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
170 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
171 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
172 void semtd::RemoveVerLabel(uint32_t verPos) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
173 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
174 if (this->VerLabels[verPos] > 0) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
175 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
176 this->VerLabels[verPos] = 0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
177 removeEdgeLabels(verPos); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
178 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
179 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
180 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
181 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
182 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
183 bool semtd::IsValidToLabel(uint32_t verPos,uint32_t verLabel) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
184 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
185 uint32_t i,tempLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
186 //uint32_t tempMax=this->edgeLabelMax; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
187 //uint32_t tempMin=this->edgeLabelMin; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
188 for (i = 1; i <= this->NumVer; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
189 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
190 tempLabel=this->VerLabels[i] + verLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
191 if (i != verPos && |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
192 this->theGraph[i][verPos] && |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
193 this->VerLabels[i] > 0 && |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
194 this->edgeLabelsUsed[tempLabel] == 1) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
195 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
196 return false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
197 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
198 /*if(tempLabel>tempMax) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
199 tempMax=tempLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
200 if(tempLabel<tempMin) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
201 tempMin=tempLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
202 if(!isValidRange(tempMin,tempMax)) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
203 return false;*/ |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
204 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
205 return true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
206 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
207 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
208 bool semtd::isValidRange(uint32_t min,uint32_t max) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
209 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
210 uint32_t delta=1+max-min; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
211 if(delta<=this->numEdges) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
212 return true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
213 return false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
214 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
215 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
216 double semtd::SemtScore() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
217 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
218 //TODO |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
219 return 0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
220 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
221 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
222 void semtd::FixLabel() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
223 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
224 //TODO |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
225 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
226 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
227 void semtd::SwapLabel() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
228 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
229 //TODO |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
230 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
231 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
232 string semtd::Print(uint32_t withDual) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
233 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
234 uint32_t i,j; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
235 string ret = ""; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
236 string n = "\n"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
237 bool dualRun=false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
238 bool keepPrinting=true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
239 while (keepPrinting) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
240 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
241 ret+="graph: "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
242 switch(this->graphType) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
243 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
244 case 3: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
245 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
246 ret+="wheel"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
247 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
248 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
249 case 4: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
250 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
251 ret+="fan"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
252 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
253 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
254 case 5: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
255 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
256 ret+="doublefan"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
257 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
258 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
259 default: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
260 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
261 ret+="unknown"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
262 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
263 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
264 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
265 ret+=" | edges: "+uint32_t_to_str(this->numEdges)+" | vertices: " + uint32_t_to_str(this->NumVer)+" | deficiencies: " + uint32_t_to_str(this->numDef) + " | "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
266 uint32_t edgeweight=0,k,edgelabel=0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
267 for (i=1;i<=this->edgeLabelAbsoluteMax;i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
268 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
269 if(this->edgeLabelsUsed[i]) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
270 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
271 edgeweight=i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
272 edgelabel=this->numEdges+this->TotalVer; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
273 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
274 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
275 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
276 if(dualRun) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
277 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
278 edgeweight=2*(this->TotalVer)+2-edgeweight; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
279 edgelabel=2*this->TotalVer+this->numEdges+1-edgelabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
280 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
281 k=edgeweight+edgelabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
282 ret+="mnum: "+uint32_t_to_str(k)+" | "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
283 for (i = 1; i <= this->NumVer; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
284 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
285 uint32_t theLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
286 if(dualRun) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
287 theLabel=this->TotalVer+1-this->VerLabels[i]; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
288 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
289 theLabel=this->VerLabels[i]; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
290 if(i==1 && this->graphType==3) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
291 ret+="c: " + uint32_t_to_str(theLabel) +" | l: "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
292 else if(i==1 && this->graphType==4) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
293 ret+="c: " + uint32_t_to_str(theLabel) +" | p: "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
294 else if(i==1 && this->graphType==5) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
295 ret+="c: " + uint32_t_to_str(theLabel) + ","; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
296 else if(i==2 && this->graphType==5) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
297 ret+=uint32_t_to_str(theLabel) + " | p: "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
298 else if(i==this->NumVer) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
299 ret+=uint32_t_to_str(theLabel) + " | def: "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
300 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
301 ret+=uint32_t_to_str(theLabel)+","; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
302 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
303 if(this->numDef>0) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
304 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
305 vector<bool> usedLabels (this->TotalVer+1,false); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
306 for(i=1;i<=this->NumVer;i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
307 usedLabels[this->VerLabels[i]]=true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
308 j=0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
309 for(i=1;i<=this->TotalVer;i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
310 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
311 uint32_t theLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
312 if(!usedLabels[i]) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
313 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
314 if(dualRun) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
315 theLabel=this->TotalVer+1-i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
316 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
317 theLabel=i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
318 if(j==this->numDef-1) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
319 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
320 if(dualRun) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
321 ret+=uint32_t_to_str(theLabel)+" (dual)"+n; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
322 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
323 ret+=uint32_t_to_str(theLabel)+n; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
324 j++; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
325 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
326 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
327 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
328 ret+=uint32_t_to_str(theLabel)+","; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
329 j++; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
330 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
331 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
332 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
333 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
334 /* |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
335 ret += n+"Deficiency: " + uint32_t_to_str(this->numDef); |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
336 ret += n+"GraphViz code: " + n + "----------------------------------"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
337 //tempstr1<<this->graphType; //TODO: graphtype is now integer instead of string. create a convert method |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
338 ret += n+"graph " + uint32_t_to_str(this->graphType)+ "{"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
339 ret += n+"graph[bgcolor=\"transparent\"]"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
340 ret += n+"node [fontname=\"Bitstream Vera Sans\", fontsize=\"22.00\", shape=circle, style=\"bold,filled\" fillcolor=white];"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
341 ret += n+"edge [style=bold];"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
342 ret += n+" "; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
343 for (i = 1; i <= this->TotalVer; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
344 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
345 ret += uint32_t_to_str(i) + ";"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
346 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
347 for (i = 1; i <= this->NumVer; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
348 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
349 for (j = i + 1; j <= this->NumVer; j++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
350 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
351 if (this->theGraph[i][j]) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
352 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
353 uint32_t theLabel; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
354 if(dualRun) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
355 theLabel=this->TotalVer+1-this->VerLabels[i]; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
356 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
357 theLabel=this->VerLabels[i]; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
358 ret += n+uint32_t_to_str(this->VerLabels[i])+ " -- " + uint32_t_to_str(theLabel)+ ";"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
359 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
360 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
361 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
362 ret += n+"}"; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
363 ret += n+"----------------------------------" + n + "End GraphViz code";*/ |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
364 if(withDual==1) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
365 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
366 withDual=0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
367 dualRun=true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
368 }else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
369 keepPrinting=false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
370 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
371 return ret; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
372 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
373 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
374 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
375 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
376 bool semtd::IsSemt() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
377 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
378 uint32_t i; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
379 if (this->isSureFail) { return false; } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
380 else |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
381 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
382 if (edgeLabelRange() == numEdges) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
383 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
384 uint32_t edgeLabelMin = this->edgeLabelMin; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
385 uint32_t edgeLabelMax = this->edgeLabelMax; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
386 for (i = edgeLabelMin; i <= edgeLabelMax; i++) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
387 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
388 if (this->edgeLabelsUsed[i] != 1) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
389 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
390 return false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
391 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
392 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
393 return true; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
394 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
395 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
396 return false; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
397 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
398 |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
399 uint32_t semtd::MinDef() |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
400 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
401 uint32_t ret=0; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
402 switch(this->graphType) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
403 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
404 case 3: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
405 switch (this->NumVer) |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
406 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
407 case 3: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
408 case 4: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
409 case 6: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
410 case 7: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
411 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
412 ret = 1; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
413 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
414 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
415 default: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
416 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
417 ret = 2; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
418 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
419 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
420 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
421 case 4: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
422 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
423 ret=1; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
424 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
425 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
426 case 5: |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
427 { |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
428 ret = (this->NumVer - 3) / 2; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
429 break; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
430 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
431 } |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
432 return ret; |
ebed2bd0d300
Initial import from svn. History be damned.
Edho P. Arief <me@myconan.net>
parents:
diff
changeset
|
433 } |