-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
588 lines (472 loc) · 27.9 KB
/
main.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
import networkx as nx
import matplotlib.pyplot as plt
from random import randint
import grinpy as gp
import queue
def RandomNNumbers (n, maxn, AlreadExist):
nums = set (AlreadExist)
while ( len(nums) < n):
nums.add(randint(0, int(maxn) - 1))
return nums
def GetMinimumConnections(VerticesNum):
Taken = set([0])
NotTaken = set(x for x in range(1, VerticesNum))
Edges = set([])
while len(NotTaken) > 0:
randNum1 = randint(min(NotTaken), max(NotTaken))
if randNum1 in NotTaken:
randNum2 = randint(min(Taken), max(NotTaken))
if randNum2 in Taken:
NotTaken.remove(randNum1)
Taken.add(randNum1)
if randNum1 > randNum2:
temp = randNum1
randNum1 = randNum2
randNum2 = temp
Edges.add((randNum1, randNum2))
return Edges
def RandomNEdges (EdgesNum, VerticesNum, MakeConnected):
Edges = set ([])
Edgesindicies = set([])
maxn = (VerticesNum * VerticesNum - VerticesNum) /2
if EdgesNum > maxn:
EdgesNum = maxn
if MakeConnected:
Edges = GetMinimumConnections(VerticesNum)
iterN = 0
for i in range(0, VerticesNum) :
for j in range(i + 1, VerticesNum):
if (i,j) in Edges:
Edgesindicies.add(iterN)
iterN = iterN +1
Edgesindicies = RandomNNumbers(EdgesNum, maxn, Edgesindicies)
print(len( Edgesindicies ))
print(Edgesindicies)
iterN = 0
for i in range(0, VerticesNum) :
for j in range(i + 1, VerticesNum):
if (iterN in Edgesindicies):
Edges.add(( i ,j))
iterN = iterN +1
return Edges
def RandomNGraph (Order, Size, MakeConnected):
RandGraph = gp.Graph()
GNodes = list(x for x in range(Order))
GEdges = RandomNEdges(Size, Order, MakeConnected)
RandGraph.add_nodes_from(GNodes)
RandGraph.add_edges_from(GEdges)
return RandGraph
#def colorGraphRecursive:
#basecase 1:
def ColorGraph(G):
colors = "bgrcmykw"
colorsrange = range (0, len(colors))
#G = nx.Graph()
hey = G.degree(G.nodes())
#print(hey)
maxdegree = max ( y for (x,y) in hey)
#print(maxdegree)
targetnodes = [(x,y) for (x,y) in hey if y == maxdegree]
#print(targetnodes)
#print(len(targetnodes))
firstnode = min (x for (x,y) in targetnodes if y == maxdegree)
#print(firstnode)
print("Given Problem:\t", hey)
print("Target Solution:\t", maxdegree, "\t", len(targetnodes), "\t", targetnodes)
print("Start Point: ", firstnode)
coloredvertices = dict()
visitedvertices = set()
added_as_next_vertice = set()
nextverticies = queue.Queue()
for x,y in targetnodes:
nextverticies.put(x)
added_as_next_vertice.add(x)
step = 0
while nextverticies.qsize() >0 :
step = step + 1
currentnode = nextverticies.get()
#print(currentnode)
if ( currentnode not in visitedvertices):
visitedvertices.add(currentnode)
neighbours = list (G.neighbors(currentnode))
for neighbour in neighbours:
if(neighbour not in added_as_next_vertice):
nextverticies.put(neighbour)
added_as_next_vertice.add(neighbour)
neighbourscolors = [color for neighbor, color in coloredvertices.items() if neighbor in neighbours]
#print(">>>>>>>",neighbourscolors)
currentcolor = min(x for x in colorsrange if x not in neighbourscolors)
print(step, ">>> \t",currentnode,"\t", currentcolor, "\t", neighbours)
coloredvertices[currentnode] = currentcolor
gotcolors = ""
visitedvertices
for node in G.nodes():
gotcolors += colors[coloredvertices[node]];
print((gotcolors))
print(coloredvertices)
print(max (x for n,x in coloredvertices.items() ) + 1 )
return gotcolors
def ColorGraph2(G,add_colors = False ,forcing = True, induction = True, max_first = True):
colors = "rbgcmykw"
got_colors = ""
g_nodes = G.nodes()
colored_nodes = dict()
for g_node in G.nodes():
colored_nodes[g_node] = 0
max_subgraphs = list(nx.find_cliques(G))
max_subgraphs.sort(key = len, reverse = True)
max_subgraph_nodes = list(max_subgraphs[0])
if (add_colors):
max_degree = 0
if (max_first):
max_degree = max([len(list (G.neighbors(x))) for x in G.nodes() ])
else :
max_degree = min([len(list (G.neighbors(x))) for x in G.nodes() ])
max_degree_nodes = [x for x in G.nodes() if len(list (G.neighbors(x))) == max_degree]
max_subgraph_nodes = [min(max_degree_nodes)]
global_colors_neighbors = dict()
global_colors_partites = dict()
for max_subgraph_node in max_subgraph_nodes:
global_colors_neighbors[max_subgraph_node] = set (G.neighbors(max_subgraph_node))
global_colors_partites[max_subgraph_node] = set ([max_subgraph_node])
colored = len(max_subgraph_nodes)
print("Start colored\t", colored)
while colored != 0:
#mirroring colors
colored = 0
current_color = 1
for max_subgraph_node in max_subgraph_nodes:
print("\t", max_subgraph_node, "\t")
colored_nodes[max_subgraph_node] = current_color
previous_neighbors_count = len (global_colors_neighbors[max_subgraph_node])
current_neighbors_increase = previous_neighbors_count
firsttime = True
while current_neighbors_increase > 0 and (firsttime or current_color == 1 ):
firsttime = False
possible_color_nodes = set()
for color_neighbor in global_colors_neighbors[max_subgraph_node]:
for possible_color_node in G.neighbors(color_neighbor):
if(possible_color_node not in global_colors_neighbors[max_subgraph_node] ):
possible_color_nodes.add(possible_color_node)
for possible_color_node in possible_color_nodes:
if(len([x for x in G.neighbors(possible_color_node) if x in possible_color_nodes]) == 0):
neighbour_colors = set([colored_nodes[node] for node in G.neighbors(possible_color_node)])
if(current_color not in neighbour_colors):
if (colored_nodes[possible_color_node] == 0):
colored_nodes[possible_color_node] = current_color
global_colors_neighbors[max_subgraph_node].add(possible_color_node)
for n in G.neighbors(possible_color_node):
global_colors_neighbors[max_subgraph_node].add(n)
print("Choosing\t", possible_color_node, "\t", current_color, "\tneighbours:\t", G.neighbors(possible_color_node), "\tColors\t", neighbour_colors)
colored = colored + 1
current_neighbors_increase = previous_neighbors_count - len(global_colors_neighbors[max_subgraph_node])
previous_neighbors_count = len(global_colors_neighbors[max_subgraph_node])
#previous algorithm continues coloring over levels even if a node was not sucessfuly colored
current_color = current_color + 1
#Writing Forced Colors
if forcing:
if colored == 0:
for g_node in g_nodes:
if (colored_nodes[g_node] == 0):
neighbours_colors = set()
for x, color in colored_nodes.items():
if x in list (G.neighbors(g_node)):
if(color != 0):
neighbours_colors.add(color)
print("Checking Forcing node:\t", g_node, "\t", G.neighbors(g_node) ,"\t", neighbours_colors)
if (len(neighbours_colors) == len(max_subgraph_nodes ) - 1):
min_colors = [x for x in range(0, len (max_subgraph_nodes) + 1) if x not in neighbours_colors or x in [0]]
colored_nodes[g_node] = max( min_colors)
if (colored_nodes[g_node] != 0):
for g_node2 in max_subgraph_nodes:
if (colored_nodes[g_node] == colored_nodes[g_node2]):
global_colors_partites[g_node2].add(g_node)
for eachneighbor in G.neighbors(g_node):
global_colors_neighbors[g_node2].add(eachneighbor)
colored = colored + 1
print("Forced\t", g_node, "\t", colored_nodes[g_node], "\t\tneighbors_colors\t:", neighbours_colors)
print(min_colors)
#inducing colors
if induction:
if colored == 0 and len([colored_nodes[x] for x,y in colored_nodes.items() if y != 0]) < len(g_nodes):
min_distinct_colors = max([ len(set([colored_nodes[neighbour] for neighbour in G.neighbors(g_node) if colored_nodes[neighbour] != 0 ])) for g_node in g_nodes if colored_nodes[g_node] == 0])
print("Max Dinstinct Colors \t", min_distinct_colors)
for g_node in g_nodes:
if (len(set([colored_nodes[neighbour] for neighbour in G.neighbors(g_node) if colored_nodes[neighbour] != 0 ])) == min_distinct_colors) :
if (colored_nodes[g_node] == 0):
neighbours_colors = set()
for x, color in colored_nodes.items():
if x in G.neighbors(g_node):
if(color != 0):
neighbours_colors.add(color)
print("Checking Inducing node:\t", g_node, "\t", G.neighbors(g_node) ,"\t", neighbours_colors)
min_colors = [x for x in range(0, len (max_subgraph_nodes) + 1) if (x not in neighbours_colors) or (x in [0])]
colored_nodes[g_node] = max(min_colors)
if (colored_nodes[g_node] != 0):
for g_node2 in max_subgraph_nodes:
if (colored_nodes[g_node] == colored_nodes[g_node2]):
global_colors_partites[g_node2].add(g_node)
for eachneighbor in G.neighbors(g_node):
global_colors_neighbors[g_node2].add(eachneighbor)
colored = colored + 1
print("Induced\t", g_node, "\t", colored_nodes[g_node], "\t\tneighbors_colors\t:", neighbours_colors)
print(min_colors)
break
#adding colors
if(add_colors):
if colored == 0 and current_color < 2:
new_color_neighbours = set()
for max_subgraph_node in max_subgraph_nodes:
for neighbor in global_colors_partites[max_subgraph_node]:
new_color_neighbours.add(neighbor)
possible_new_color_main_nodes = set([x for x in G.neighbors(neighbor) if neighbor in new_color_neighbours])
possible_new_color_main_nodes_disjoint = set()
for node in possible_new_color_main_nodes:
if (len([x for x in G.neighbors(node) if node in possible_new_color_main_nodes]) ==0):
possible_new_color_main_nodes_disjoint.add(node)
for possible_new_color_main_node in possible_new_color_main_nodes:
if (colored_nodes[possible_new_color_main_node] == 0):
neighbours_colors = set()
for x, color in colored_nodes.items():
if x in G.neighbors(possible_new_color_main_node):
if(color != 0):
neighbours_colors.add(color)
print("Checking new coloring node:\t", possible_new_color_main_node, "\t", G.neighbors(possible_new_color_main_node) ,"\t", neighbours_colors)
if (len(neighbours_colors) == len(max_subgraph_nodes)):
colored_nodes[possible_new_color_main_node] = current_color
max_subgraph_nodes.append(possible_new_color_main_node)
global_colors_partites[possible_new_color_main_node] = set([possible_new_color_main_node])
global_colors_neighbors[possible_new_color_main_node] = set(G.neighbors(possible_new_color_main_node))
colored = colored + 1
print("error")
print("error")
print("error")
print("New Colored\t", possible_new_color_main_node, "\t", colored_nodes[possible_new_color_main_node], "\t\tneighbors_colors\t:", neighbours_colors)
print("error")
print("error")
print("error")
previous_neighbors_count = len (global_colors_neighbors[possible_new_color_main_node])
current_neighbors_increase = previous_neighbors_count
firsttime = True
while current_neighbors_increase > 0 & firsttime:
firsttime = False
possible_color_nodes = set()
for color_neighbor in global_colors_neighbors[possible_new_color_main_node]:
for possible_color_node in G.neighbors(color_neighbor):
if(possible_color_node not in global_colors_neighbors[possible_new_color_main_node] ):
possible_color_nodes.add(possible_color_node)
for possible_color_node in possible_color_nodes:
if(len([x for x in G.neighbors(possible_color_node) if x in possible_color_nodes]) == 0):
neighbour_colors = set([colored_nodes[node] for node in G.neighbors(possible_color_node)])
if(current_color not in neighbour_colors):
if (colored_nodes[possible_color_node] == 0):
colored_nodes[possible_color_node] = current_color
global_colors_neighbors[possible_new_color_main_node].add(possible_color_node)
for n in G.neighbors(possible_color_node):
global_colors_neighbors[possible_new_color_main_node].add(n)
print("Choosing\t", possible_color_node, "\t", current_color, "\tneighbours:\t", G.neighbors(possible_color_node), "\tColors\t", neighbour_colors)
colored = colored + 1
current_neighbors_increase = previous_neighbors_count - len(global_colors_neighbors[possible_new_color_main_node])
previous_neighbors_count = len(global_colors_neighbors[possible_new_color_main_node])
break
if forcing:
for g_node in g_nodes:
if (colored_nodes[g_node] == 0):
neighbours_colors = set()
for x, color in colored_nodes.items():
if x in list (G.neighbors(g_node)):
if(color != 0):
neighbours_colors.add(color)
print("Checking Forcing node:\t", g_node, "\t", G.neighbors(g_node) ,"\t", neighbours_colors)
if (len(neighbours_colors) == len(max_subgraph_nodes ) - 1):
min_colors = [x for x in range(0, len (max_subgraph_nodes) + 1) if x not in neighbours_colors or x in [0]]
colored_nodes[g_node] = max( min_colors)
if (colored_nodes[g_node] != 0):
for g_node2 in max_subgraph_nodes:
if (colored_nodes[g_node] == colored_nodes[g_node2]):
global_colors_partites[g_node2].add(g_node)
for eachneighbor in G.neighbors(g_node):
global_colors_neighbors[g_node2].add(eachneighbor)
colored = colored + 1
print("Forced\t", g_node, "\t", colored_nodes[g_node], "\t\tneighbors_colors\t:", neighbours_colors)
print(min_colors)
print("Now colored\t", colored)
for g_node in G.nodes():
got_colors += colors[colored_nodes[g_node]]
return got_colors, len(max_subgraph_nodes), colored_nodes
def ColorGraph3(G,mirror = True, add_colors = False ,forcing = True, induction = True, max_first = True):
colors = "rbgcmykw"
got_colors = ""
hamoone, hamotwo, colored_nodes = ColorGraph2(G, add_colors=add_colors ,forcing=forcing, induction=induction, max_first=max_first)
g_nodes = G.nodes()
pivots_neighbors = dict()
for node,color in colored_nodes.items():
if color == 1:
pivots_neighbors[node] = set(G.neighbors(node))
max_degree = 0
if (max_first):
max_degree = max([len(list (G.neighbors(x))) for x in G.nodes() ])
else :
max_degree = min([len(list (G.neighbors(x))) for x in G.nodes() ])
max_degree_nodes = [x for x in G.nodes() if len(list (G.neighbors(x))) == max_degree]
main_pivot = min(max_degree_nodes)
# colored_nodes[main_pivot] = 1
# pivots_neighbors = dict()
# pivots_neighbors[main_pivot] = set(G.neighbors(main_pivot))
possible_colors = set([1,2,3,4,5,6,7,8,9])
#choosing pivots
# colored = 1
pivot_class_neighbors = set(G.neighbors(main_pivot))
previous_neighbors_count = len(pivot_class_neighbors)
current_neighbors_increase = previous_neighbors_count
while False:
possible_pivots = set()
for pivot_neighbor in pivot_class_neighbors:
for possible_pivot in G.neighbors(pivot_neighbor):
if(possible_pivot not in pivot_class_neighbors):
possible_pivots.add(possible_pivot)
print(possible_pivots)
for possible_pivot in possible_pivots:
if(len([x for x in G.neighbors(possible_pivot) if x in possible_pivots]) == 0):
neighbour_colors = set([colored_nodes[node] for node in G.neighbors(possible_pivot)])
if(1 not in neighbour_colors):
if (colored_nodes[possible_pivot] == 0):
pivots_neighbors[possible_pivot] = set(G.neighbors(possible_pivot))
colored_nodes[possible_pivot] = 1
for n in G.neighbors(possible_pivot):
pivot_class_neighbors.add(n)
print("Initializing\t", possible_pivot, "\t", 1, "\tneighbours:\t", G.neighbors(possible_pivot), "\tColors\t", neighbour_colors)
colored = colored + 1
current_neighbors_increase = previous_neighbors_count - len(pivot_class_neighbors)
previous_neighbors_count = len(pivot_class_neighbors)
colored = len(colored_nodes.items())
print("Start colored\t", colored)
while colored != 0:
#choosing mirrors
while colored != 0:
colored = 0
if mirror:
for pivot, first_neighbors in pivots_neighbors.items():
for first_neighbor in first_neighbors:
bad_common_num = 0
common = set()
for pvt,neghbrs in pivots_neighbors.items():
for x in G.neighbors(first_neighbor):
if x in neghbrs and colored_nodes[x] == 0:
common.add(x)
if x in common and x not in list(G.neighbors(first_neighbor)):
bad_common_num = bad_common_num + 1
print("Checking fn\t", first_neighbor,"\t",list(G.neighbors(first_neighbor)),"\twith\t", common, "\tbadnum\t", bad_common_num)
if bad_common_num == 0 and colored_nodes[first_neighbor] == 0:
first_pvt_common_neighbors = set()
for cmn in common:
for x in G.neighbors(cmn):
first_pvt_common_neighbors.add(x)
not_possible_colors_for_common = set(colored_nodes[x] for x in first_pvt_common_neighbors)
possible_colors_for_common = set([x for x in possible_colors if x not in not_possible_colors_for_common])
not_possible_colors_for_mirror = set(colored_nodes[x] for x in G.neighbors(first_neighbor))
possible_colors_for_mirror = set([x for x in possible_colors if x not in not_possible_colors_for_mirror])
print("mirror colors:\t", possible_colors_for_mirror, "\tneighbors colors\t", possible_colors_for_common)
if (len (set([x for x in possible_colors_for_common or x in possible_colors_for_mirror])) < 2 ):
if (len(possible_colors_for_common) < 1 or len(possible_colors_for_mirror) < 1):
break
if (True):
mirror_color = min(possible_colors_for_mirror)
common_color = min([x for x in possible_colors_for_common if x != mirror_color])
colored_nodes[first_neighbor] = mirror_color
for cmn in common:
colored_nodes[cmn] = common_color
else:
common_color = min(possible_colors_for_common)
mirror_color = min([x for x in possible_colors_for_mirror if x != common_color])
colored_nodes[first_neighbor] = mirror_color
for cmn in common:
colored_nodes[cmn] = common_color
current_color = max(possible_colors) + 1
#Writing Forced Colors
if False:
if colored == 0:
for g_node in g_nodes:
if (colored_nodes[g_node] == 0):
neighbours_colors = set()
for x, color in colored_nodes.items():
if x in list (G.neighbors(g_node)):
if(color != 0):
neighbours_colors.add(color)
print("Checking Forcing node:\t", g_node, "\t", G.neighbors(g_node) ,"\t", neighbours_colors)
if (len(neighbours_colors) == len(possible_colors ) - 1):
min_colors = [x for x in range(0, len (possible_colors) + 1) if x not in neighbours_colors or x in [0]]
colored_nodes[g_node] = max( min_colors)
if (colored_nodes[g_node] != 0):
colored = colored + 1
print("Forced\t", g_node, "\t", colored_nodes[g_node], "\t\tneighbors_colors\t:", neighbours_colors)
print(min_colors)
#inducing colors
if False:
if colored == 0 and len([colored_nodes[x] for x,y in colored_nodes.items() if y != 0]) < len(g_nodes):
min_distinct_colors = max([ len(set([colored_nodes[neighbour] for neighbour in G.neighbors(g_node) if colored_nodes[neighbour] != 0 ])) for g_node in g_nodes if colored_nodes[g_node] == 0])
print("Max Dinstinct Colors \t", min_distinct_colors)
for g_node in g_nodes:
if (len(set([colored_nodes[neighbour] for neighbour in G.neighbors(g_node) if colored_nodes[neighbour] != 0 ])) == min_distinct_colors) :
if (colored_nodes[g_node] == 0):
neighbours_colors = set()
for x, color in colored_nodes.items():
if x in G.neighbors(g_node):
if(color != 0):
neighbours_colors.add(color)
print("Checking Inducing node:\t", g_node, "\t", G.neighbors(g_node) ,"\t", neighbours_colors)
min_colors = [x for x in range(0, len (possible_colors) + 1) if (x not in neighbours_colors) or (x in [0])]
colored_nodes[g_node] = max(min_colors)
if (colored_nodes[g_node] != 0):
colored = colored + 1
print("Induced\t", g_node, "\t", colored_nodes[g_node], "\t\tneighbors_colors\t:", neighbours_colors)
print(min_colors)
break
print("Now colored\t", colored)
for g_node in G.nodes():
got_colors += colors[colored_nodes[g_node]]
return got_colors, len(possible_colors)
def GetColorGroundTruth(G):
GotColors = ""
return GotColors
def __main__ ():
GOrder = 15
GSize = 30
MakeConnectedGraph = True
G = RandomNGraph(GOrder, GSize, MakeConnectedGraph)
GColors = "rrrgggbbbm" + "rrrgggbbbm" + "rrrgg"
print("\t\t\t##########Test One##########")
GColors2_Forcing,num1,hamo1 = ColorGraph2(G,add_colors= False, forcing= True, induction=False)
print("\t\t\t##########Test Two##########")
GColors2_Induction, num2,hamo2 = ColorGraph2(G,add_colors= False, forcing= True, induction=True)
print("\t\t\t##########Test Three########")
GColors2_addcolors_Forcing,num3,hamo3 = ColorGraph2(G,add_colors= True, forcing= True, induction=False)
print("\t\t\t##########Test Four#########")
GColors2_addcolors_Induction,num4,hamo4 = ColorGraph2(G, add_colors= True, forcing= True, induction= True)
print("\t\t\t##########Test Five########")
GColors2_addcolors_Forcing_min,num5 = ColorGraph3(G,add_colors= True, forcing= True, induction=False, max_first= True)
print("\t\t\t##########Test Six#########")
GColors2_addcolors_Induction_min,num6 = ColorGraph3(G, add_colors= True, forcing= True, induction= True, max_first= True)
print(G.order())
print(G.size())
planarok, otherg = gp.check_planarity(G);
print(planarok)
if (not planarok):
print("Elhamdullah")
print(gp.chromatic_number(G))
print(num1,"\t", num2, "\t", num3, "\t",num4, "\t", num5, "\t", num6)
plt.subplot(321)
nx.draw(G, node_color = GColors2_Forcing, with_labels = True)
plt.subplot(322)
nx.draw(G, node_color = GColors2_Induction, with_labels = True)
plt.subplot(323)
nx.draw(G, node_color = GColors2_addcolors_Forcing, with_labels = True)
plt.subplot(324)
nx.draw(G, node_color = GColors2_addcolors_Induction, with_labels = True)
plt.subplot(325)
nx.draw(G, node_color = GColors2_addcolors_Forcing_min, with_labels = True)
plt.subplot(326)
nx.draw(G, node_color = GColors2_addcolors_Induction_min, with_labels = True)
plt.show()
return 0
__main__()