Question: Two colors dye the same Vertex of graph

I'm thinking of better demonstrating the cartesian product of a graph.
With the help documentation, we can easily find the cartesian product of two graphs.

with(GraphTheory):
G := CycleGraph([v__1,v__2,v__3,v__4]);
H:=Graph({{u__1,u__2}}):
DrawGraph(G,size=[250,250],stylesheet=[vertexborder=false,vertexpadding=10,edgecolor = "Red",
vertexcolor="navy",edgethickness=3]);
DrawGraph(H,size=[250,250],stylesheet=[vertexborder=false,vertexpadding=10,edgecolor = "Blue",
vertexcolor="Gold",edgethickness=3]);


GH:=CartesianProduct(G,H)
DrawGraph(GH,style=spring)

 

 

 

When I saw Wikipedia's demo diagram, https://en.wikipedia.org/wiki/Cartesian_product_of_graphs

I was fascinated,and I also wanted to visually reflect the nature of Cartesian product by doing different staining of vertices.
It is easy for me to dye the vertices in one color, but it is difficult for 
two different colors .

Please Wait...