# How to draw a combinatorial graph with different colors of edges?

For example, like above. I've read some examples and descriptions in here, but couldn't figured it out.

-
Have you tried writing something down ? If so, please, share your code. – Sektor Jul 6 '14 at 19:48
Do you need the Combinatorica package? If not, just use EdgeStyle :) – Öskå Jul 6 '14 at 21:17
@Novice Looks like a PetersonGraph. Where did you get the image from? – eldo Jul 6 '14 at 21:48

I post this for illustrative purposes based on the title of the question (which is somewhat ambiguous). I agree as Szabolcs advice re: looking at documentation, which is good. Here are some motivating examples:

Your example: another way (exploiting Szabolcs observation):

cg = CompleteGraph[6];
el = EdgeList[cg];
path = EdgeList[CycleGraph[6]];
Graph[EdgeList@cg,
EdgeStyle ->
Join[(# -> {Red, Thickness[0.01]} & /@ path), {Blue,
Thickness[0.01]}]]


or if you wanted different colors on the hightlighted path:

  Graph[EdgeList@cg,EdgeStyle ->
Join[MapThread[#1 -> {RGBColor[#2], Thickness[0.01]} &, {path,
RandomReal[{0, 1}, {6, 3}]}], {Blue, Thickness[0.01]}]]

![enter image description here][2]


A modification of the documentation to illustrate styles for HighlightGraph:

ged = GraphElementData["GraphHighlightStyle"]


=>:

{Automatic, "Dashed", "Dotted", "Thick", "VertexConcaveDiamond",
"DehighlightGray", "DehighlightHide"}


Grid[Partition[
Column /@
Transpose[{Rest@ged,
HighlightGraph[
cg, {1, 2 \[UndirectedEdge] 4, 3 \[UndirectedEdge] 6},
GraphHighlightStyle -> #] & /@ Rest[ged]}], 3], Frame -> All]


Finally, you have a lot of control with wrapper Style or using EdgeStyle option of built in Graph function:

Using Style

Graph[
{el,RandomReal[{0, 1}, {Length@el, 3}]}]
]


Using EdgeStyle:

Graph[MapThread[
Style[#1, RGBColor[#2], Thick] &, {el,
RandomReal[{0, 1}, {Length@el, 3}]}]]]
Graph[el,
EdgeStyle ->
MapThread[#1 -> {RGBColor[#2], Thick} &, {el,
RandomReal[{0, 1}, {Length@el, 3}]}]]


-

Look up HighlightGraph.

HighlightGraph[
CompleteGraph[5],
EdgeList@CycleGraph[5]
]
`

(This solution is based on the accidental fact that CompleteGraph and CycleGraph name and connect the vertices in the same order, i.e. 1--2--3--4--5--1)

-
I would have written: "The solution is based on a thorough forensic inquiry on the accidental fact..." :) – eldo Jul 6 '14 at 22:56

It looks like you want to make an edge rendering function: http://reference.wolfram.com/mathematica/ref/EdgeRenderingFunction.html

-