# Visualize difference between members of the list

I want to visualize the difference between members of a set:

set = {20, 36, 70, 96, 152, 301}


This way I get the diffs:

diffs = Select[#[[2]] - #[[1]] & /@ Tuples[{set, set}], # > 0 &]

{16, 50, 76, 132, 281, 34, 60, 116, 265, 26, 82, 231, 56, 205, 149}


But how can I put the diffs as a caption over graph like lines between members?

-

Borrowing some code from Kuba's:

set = {20, 36, 70, 96, 152, 301}
Graph[DirectedEdge @@@ #,
VertexShapeFunction -> "Square",
VertexSize -> {.2, .1},
VertexLabels -> Placed["Name", Center],
VertexLabelStyle -> Directive[FontFamily -> "Arial", 10],
GraphLayout -> "CircularEmbedding",
EdgeLabels -> ((DirectedEdge[##] -> Placed[#2 - #, .85]) & @@@ #)] &@Subsets[set, {2}]


Edit

In fact, you could apply any nice formatting to the edges. The following applies a color proportional to its value:

set = {20, 36, 70, 96, 152, 301};
{min, max} = {Min@#, Max@#} &[Subtract @@@ -Subsets[set, {2}]]
Graph[Property[DirectedEdge @@ #,
EdgeStyle -> {Thick, ColorData["Rainbow"][
Rescale[#[[2]] - #[[1]], {min, max}]]}] & /@ #,
VertexShapeFunction -> "Square",
VertexSize -> {.2, .1},
VertexLabels -> Placed["Name", Center],
VertexLabelStyle -> Directive[FontFamily -> "Arial", 10],
GraphLayout -> "CircularEmbedding",
EdgeLabels -> ((DirectedEdge[##] -> Placed[#2 - #, .85]) & @@@ #)]
&@Subsets[set, {2}]


-
set = {20, 36, 70, 96, 152, 301}

Graph[DirectedEdge @@@ #, EdgeLabels -> ((DirectedEdge[##] -> (#2 - #)) & @@@ #),
VertexLabels -> Thread[set -> set], EdgeLabelStyle -> Bold,
VertexLabelStyle -> Directive[Bold, 20]
] &[Tuples[set, {2}]]


 Graph[DirectedEdge @@@ #, EdgeLabels -> ((DirectedEdge[##] -> (#2 - #)) & @@@ #),

@MohsenAfshin You could try Subsets[set, {2}] rather than Tuples... – cormullion Dec 20 '13 at 12:54
@MohsenAfshin take a look at GraphLayout, e.g "CircularEmbedding" – Kuba Dec 20 '13 at 13:05