import math
#format here:
#
# tuple (V,E)
# here V is either a set of vertices
# or a dictionary of vertices with values locations
# E is a dictionary with keys vertex pairs and values multiplicities


stardic={3:[(1,1,1),(3,1,1),(4,1,1)],4:[(1,1,1,1),(3,1,1,1)],5:[(1,1,1,1,1),],6:[(1,1,1,1,1,1),]}

graphs={}
graphs['isolated_vertex']=({0:(0,0)},{})
graphs['isolated_edge'] = ({0:(0,0),1:(0,1)},{(0,1):1})

for j in range(3,7):
	graphs['theta'+str(j)] = ({0:(0,0),1:(1,0)},{(0,1):j})
for j in range(3,7):
	for edgecount in stardic[j]:
		this_edges={(0,k):edgecount[k-1] for k in range(1,j+1)}
		this_nodes={0:(0,0)}
		for i in range(j):
			angle = 2*i*math.pi/j-math.pi/2
			this_nodes[i+1] = (round(math.cos(angle),2),round(math.sin(angle),2))
		graphname='star'+str(j)+''.join(['_'+str(valence) for valence in edgecount if valence !=1])

		graphs[graphname] = (this_nodes,this_edges)

for j,k,l in [(1,2,1), (1,3,1), (1,4,1),(3,2,1)]:
	graphs['a_graph_'+str(j)+'_'+str(k)+'_'+str(l)]=({0:(0,0) , 1:(0,1), 2:(0,2),3:(0,3)},{(0,1):j,(1,2):k,(2,3):l})

for j,k in [(3,1),(4,1),(5,1),(3,3)]:
	graphs['dart_graph_'+str(j)+'_'+str(k)]=({0:(0,0),1:(0,1),2:(0,2)},{(0,1):j,(1,2):k})

for j,k,l in [(2,2,1),(2,2,2),(3,2,1)]:
	graphs['triangle_graph_'+str(j)+'_'+str(k)+'_'+str(l)]=({0:(0,0),1:(-.5,-3**.5/2), 2:(.5,-3**.5/2)},{(0,1):j,(0,2):k,(1,2):l},.25)

for j,k,l,m in [(1,1,2,1),(1,1,3,1),(2,2,1,1),(2,1,2,1)]:
	graphs['triangle_graph_horn_'+str(j)+'_'+str(k)+'_'+str(l)+'_'+str(m)]=({0:(0,0),1:(-.5,-3**.5/2), 2:(.5,-3**.5/2), 3:(0,1)},{(0,1):j,(0,2):k,(1,2):l,(0,3):m},.25)
for j,k,l,m in [(1,1,2,1),(1,1,3,1)]:
	graphs['y_'+str(j)+'_'+str(k)+'_'+str(l)+'_'+str(m)]=({0:(0,0),1:(0,-1),2:(0,-2),3:(-3**.5/2,.5),4:(3**.5/2,.5)},{(0,1):l,(1,2):m,(0,3):j,(0,4):k})

graphs['square_2_1_2_1']=({0:(0,0),1:(0,1),2:(1,1),3:(1,0)},{(0,1):1,(1,2):2,(2,3):1,(3,0):2},.25)
graphs['K4']=({0:(0,0),1:(0,1),2:(-3**.5/2,-.5),3:(3**.5/2,-.5)},{(0,1):1,(1,2):1,(1,3):1,(2,3):1,(0,3):1,(0,2):1})
graphs['caterpillar']=({0:(0,0),1:(0,1),2:(0,2),3:(0,3),4:(0,4)},{(0,1):1,(1,2):2,(2,3):2,(3,4):1})
graphs['hairytriangle']=({0:(0,0),1:(-.5,-3**.5/2), 2:(.5,-3**.5/2), 3:(-.5,3**.5/2),4:(.5,3**.5/2)},{(0,1):1,(0,2):1,(1,2):2,(0,3):1,(0,4):1},.25)
graphs['bull']=({0:(0,0),1:(-.5,-3**.5/2), 2:(.5,-3**.5/2), 3:(-.5-3**.5/2,-3**.5/2-.5),4:(.5+3**.5/2,-3**.5/2-.5)},{(0,1):2,(0,2):1,(1,2):1,(1,3):1,(2,4):1},.25)
graphs['augmented_triangle']=({0:(0,0),1:(-.5,-3**.5/2), 2:(.5,-3**.5/2), 3:(0,1),4:(-.5-3**.5/2,-3**.5/2-.5),5:(.5+3**.5/2,-3**.5/2-.5)},{(0,1):1,(0,2):1,(1,2):1,(0,3):1,(1,4):1,(2,5):1})
graphs['cross']=({0:(0,0) , 1:(0,1), 2:(0,2),3:(0,3),4:(-1,2),5:(1,2)},{(0,1):1,(1,2):2,(2,3):1,(2,4):1,(2,5):1})
graphs['bi_y']=({0:(-3**.5/2,.5),1:(3**.5/2,.5),2:(0,0),3:(0,-1),4:(-3**.5/2,-1.5),5:(3**.5/2,-1.5)},{(0,2):1,(1,2):1,(2,3):2,(3,4):1,(3,5):1})

extragraphs={}
extragraphs['K5minus2']=({0:(0,0),1:(1,0),2:(0,1),3:(1,1),4:(.5,1.5)},{(0,1):1,(0,2):1,(0,4):1,(1,3):1,(1,4):1,(2,3):1,(2,4):1,(3,4):1}) #takes less than a minute
extragraphs['K5minus1']=({0:(0,0),1:(1,0),2:(0,1),3:(1,1),4:(.5,1.5)},{(0,1):1,(0,2):1,(0,3):1,(0,4):1,(1,3):1,(1,4):1,(2,3):1,(2,4):1,(3,4):1}) #takes seven minutes

for j in range(3,20):
	extragraphs['theta'+str(j)] = ({0:(0,0),1:(1,0)},{(0,1):j})

extragraphs['K5']=({0:(0,0),1:(1,0),2:(0,1),3:(1,1),4:(.5,1.5)},{(0,1):1,(0,2):1,(0,3):1,(0,4):1,(1,2):1,(1,3):1,(1,4):1,(2,3):1,(2,4):1,(3,4):1})
