Coloring of graph
from random import randint #todo #chromatic number #currently supporting in max 4 color graph n=input("Enter Your vertex seprated by space:").split() vac={} for vertex in n: c=input(f"{vertex} is connected to? give value seprated by space:") vac[vertex]=c.split() CV=[] CG={} first=True for vertex in n: colors=["RED","GREEN","BLUE","YELLOW"] if first==True: first=False RC=colors[randint(0,len(colors)-1)] CG[vertex]=RC CV.append(vertex) continue temp2=vac[vertex] for conn in temp2: if conn in CG: CP=CG[conn] CI=colors.index(CP) colors.pop(CI) CG[vertex]=colors[randint(0,len(colors)-1)] CV.append(vertex) print(CG)