This code generates a community structure where each community is shown with a different color. The same color is used for bars within a community and outgoing edges from that community. I would like to have the same bar chart, with two modifications:
- make all within-community edges transparent (very low opacity);
- give a name for each community on the edge of the circle above the community bars.
The code in the link is too complex for me to understand!
EDIT
ClearAll[circleToCoords, poincareESF, VSF]
el = {"str4" -> "scst", "ma15" -> "srtl", "ma15" -> "shot",
"ma15" -> "str4", "ma15" -> "ma8", "ma15" -> "str3",
"sfin" -> "shot", "sfin" -> "ma6"};
community = {{"ma15", "srtl", "ma8", "str3"}, {"shot", "sfin",
"ma6"}, {"str4", "scst"}};
valueAdded = {"str4" -> 12, "scst" -> 34, "ma15" -> 51, "srtl" -> 80,
"shot" -> 45, "ma8" -> 68, "str3" -> 34, "sfin" -> 56, "ma6" -> 73};
circleToCoords[Circle[ctr_, rad_, {a1_, a2_}]] :=
Module[{al =
Subdivide[a1, a2, 50]}, (ctr + rad {Cos[#1], Sin[#1]} &) /@ al];
poincareESF = Module[{}, GraphComputation`GraphPropertyChart;
ReplaceAll[c_Circle :> Arrow@circleToCoords[c]]@
GraphComputation`GraphChartDump`geo[0.99 First@#, 0.99 Last@#,
"segment"]] &;
VSF[shape_ : "Bar"][clr_, lbl_, val_, vcount_, gap_ : .2, fs_ : .05] :=
Module[{seg, angle = ArcTan @@ #,
width = (1 - gap) 2 Pi/(1 + vcount),
off = If[0 < ArcTan @@ # < Pi, 1, -1],
tr = If[shape == "Bar", TranslationTransform[val #],
Map[(1 + val) # &]]},
seg = {Cos@#, Sin@#} & /@
Subdivide[angle - width/2, angle + width/2, 50];
{clr,
Text[Style[lbl, Darker@clr,
FontSize ->
Scaled[fs]], (1 + val) #, {0, -off 1.5}, -off Cross@#],
Polygon[Join[seg, tr@Reverse[seg]]]}] &;
vA = Normalize[Association@valueAdded, Max];
groupColors = ColorData["Rainbow"] /@ Subdivide[-1 + Length@community];
clrRules =
Join @@ MapThread[(x |-> Blend[{#, White}, x]) /@
Normalize[#2, Total] &]@{groupColors,
Query[#]@vA & /@ community};
lblRules = AssociationThread[Join @@ community, Join @@ community];
vertexlist = Join @@ community;
gap = .2;
vertexCoordinates =
TakeList[Rest@CirclePoints[{1, 0}, 1 + Length@vertexlist],
Length /@ community]
barcount = Length[vertexlist];
Graph[vertexlist, el, VertexCoordinates -> Join @@ vertexCoordinates,
EdgeShapeFunction -> poincareESF,
VertexShapeFunction -> (VSF[][clrRules@#2, lblRules@#2, vA@#2,
barcount, gap][##] &),
EdgeStyle -> {e_ :>
Directive[Thick, Opacity[1], Arrowheads[{{Large, .75}}],
clrRules[e[[1]]]]}, ImageSize -> Large, PlotRange -> 2,
ImagePadding -> 30,
Prolog -> {AxisObject[
Line[{{1, 0}, {2, 0}}], {0, Max@Values@valueAdded},
LabelStyle -> 14,
AxisLabel -> Placed["Value Added", {1/2, {1/2, 3/2}}],
TickLabelPositioning -> "Tip"], Thin, Gray,
Circle[{0, 0}, 1 + #] & /@ Subdivide[5]}]
generates: