Basic Examples (2)
Basic Examples
(2)
Define a graph and find a proper edge coloring:
In[25]:=
graph=Graph[{ab,bc,cd,da,de}];coloring=[graph]
Out[26]=
ab1,bc3,cd2,ad3,de1
Define a function for plotting a proper edge coloring:
In[27]:=
colorAssociation[graph_]:=With[{colors=Range[Max[VertexDegree[graph]]+1]},AssociationMap[Function[color,Hue[color/Length[colors]]],colors]]edgeColoringPlot[graph_,coloring_]:=SetProperty[graph,{VertexLabels->"Name",EdgeLabelsNormal[coloring],EdgeStyleNormal[Map[colorAssociation[graph],coloring]]}]
Plot the proper edge coloring:
In[29]:=
edgeColoringPlot[graph,coloring]
Out[29]=
———
Find a proper edge coloring for the Petersen graph:
In[30]:=
pg=PetersenGraph[5,2];[pg]
Out[31]=
134,142,161,243,252,271,353,381,491,5101,673,6102,784,892,9103
Plot it:
In[32]:=
edgeColoringPlot[pg,%]
Out[32]=