Consider the list {1,2,3,4,3,4,2,1}
. I want to label these points on circle the way they appear on list(clockwise, counter clock wise doesn't matter). After that I want to connect same points by straight lines. I am not sure how to do this. Any comment appreciated.
I tried:
a = {1, 2, 3, 4, 3, 4, 2, 1};
b = DeleteDuplicates[a];
c1 = Flatten[Position[a, #, 1][[1]] & /@ b];
c2 = Flatten[Position[a, #, 1][[2]] & /@ b];
pts = Table[{2 Cos[t], 2 Sin[t]}, {t, 0, 2 Pi, 2 Pi/8}];
f[x_] := Graphics[Line[{pts[[c1[[x]]]], pts[[c2[[x]]]]}]];
But this give lines separate from each other. Also How do you add circle to that? After @cormullion answer I removed my function. Now I have what I want but without labels.
a = {1, 2, 3, 4, 5, 1, 2, 3, 5, 4};
b = DeleteDuplicates[a];
c2 = Flatten[Position[a, #, 1][[2]] & /@ b];
c1 = Flatten[Position[a, #, 1][[1]] & /@ b];
r = 2;(*radius*)
pts = Table[{r*Cos[t], r*Sin[t]}, {t, 0, 2 Pi, 2 Pi/Length[a]}];
Graphics[{Circle[{0, 0}, r],
Line[{pts[[c1[[#]]]], pts[[c2[[#]]]]}] & /@ Range[Length[b]]} ]