################################################# # Spring 2025 Valentine Submission - Pablo Blanco # Uses the GraphTheory package to draw a heart. ################################################# with(GraphTheory): LoveGraph:=proc(n) local E,G,vp,i,hgt: hgt:= 1.1: # height factor E:={seq({i,i+1},i=1..2*n+5),{1,2*n+6}, #heart outline {n+2,2*n+4}, {n+2,2*n+6}, {2*n+6,2*n+4}, {n+2,2*n+3},{n+2,1} }: G:=Graph(2*n+6,E): vp:=[[2,0], seq(evalf([cos(3.141*(i)/(n+1))+1,hgt*sin(3.141*(i)/(n+1))]) ,i=1..n), [0,0], seq(evalf([cos(3.141*(i)/(n+1))-1,hgt*sin(3.141*(i)/(n+1))]) ,i=1..n), [-2,0], [-1,-hgt^2],[0,-2*hgt^2], # bottom heart tip [1,-hgt^2]]: SetVertexPositions(G,vp): G: end: n:=80: ## change this to increase or decrease heart resolution. G:=LoveGraph(n): HighlightEdges(G,[seq({i,i+1},i=1..2*n+5),{1,2*n+6}],stylesheet=[color="Red", thickness=3]): DrawGraph(G,stylesheet=[vertexcolor="Pink"]); print(`I love Algorithmic Graph Theory!`);