This code:
ClearAll[wam, vLabels, sa, wag, cs, evc, cause, effect, chartData];
(* convert the matrix into a directed graph *)
wam = {{0, 0.03, 0, 0.03, 0.02, 0.04, 0.02, 0, 0.01, 0.01, 0.02, 0.03,
0.01, 0.02, 0.02}, {0.05, 0, 0.07, 0, 0, 0, 0.03, 0.03, 0, 0.01,
0.06, 0.04, 0.01, 0.04, 0.04}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0.06,
0, 0, 0.07, 0, 0}, {0.05, 0, 0.03, 0, 0.04, 0.05, 0.03, 0.02, 0,
0.01, 0.02, 0.03, 0.01, 0.02, 0.03}, {0.06, 0, 0, 0, 0, 0.05,
0.04, 0.06, 0.03, 0.08, 0.06, 0.05, 0.03, 0.07, 0.06}, {0.01,
0.02, 0.07, 0.03, 0.06, 0, 0.02, 0.01, 0.06, 0.01, 0.09, 0.05,
0.07, 0.02, 0.03}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02, 0.06, 0.06,
0.01, 0, 0}, {0, 0.05, 0.06, 0.06, 0.06, 0.05, 0.09, 0, 0.06,
0.01, 0.02, 0.07, 0, 0.15, 0.02}, {0, 0, 0, 0, 0, 0, 0, 0, 0,
0.07, 0, 0, 0.04, 0, 0}, {0.01, 0.07, 0.03, 0.04, 0, 0.04, 0.05,
0.08, 0.06, 0, 0.03, 0.02, 0.01, 0.03, 0.09}, {0.04, 0.07, 0.05,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03, 0, 0}, {0, 0.01, 0.06, 0, 0.01,
0.07, 0.009`, 0.006`, 0.007`, 0.012`, 0.008`, 0, 0, 0.011`,
0.01`}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.01, 0, 0.06,
0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0,
0, 0, 0, 0.05, 0, 0, 0, 0, 0, 0}};
vLabels = {1->AGF, 2->CO12, 3->MA1, 4->MA2, 5->EGW, 6->CST, 7->WHS, 8->HOT, 9->TSC, 10->FIN, 11->EST, 12->ADM, 13->EDU, 14->HLT, 15->ENT};
vnames = {"AGF","CO12","MA1","MA2","EGW","CST","WHS","HOT","TSC","FIN","EST","ADM","EDU","HLT","ENT"};
sa = SparseArray[wam];
wag = Graph[sa["NonzeroPositions"], EdgeWeight -> sa["NonzeroValues"],
DirectedEdges -> True, EdgeLabels -> "EdgeWeight"];
(* compute some statistics *)
evc = EigenvectorCentrality[wag] /. vLabels;
cs = FindGraphCommunities[wag] /. vLabels;
nghEdges = EdgeList[ NeighborhoodGraph[wag, 4]] /. vLabels;
(* Bubble chart *)
cause = Total[wam, {2}];
effect = Total@wam;
chartData = Transpose@{cause, effect, evc};
BubbleChart[
<|Thread[vnames -> chartData]|>,
ChartLabels -> Automatic,
Frame -> True,
FrameLabel -> {Style["Cause", Bold], Style["Effect", Bold]},
RotateLabel -> True,
ImageSize -> 300
]
produces:
I want to further extend this bubble chart by adding 4 pieces of information:
- Assign the same color for community members in each community;
- Show directed edges from a given vertex
V1
by usingNeighborhoodGraph[g,V1]
; - The final
Manipulate[.]
code should allow for a selection ofNeighborhoodGraph[.]
vertexV1
usingControlType -> Setter
for vertices. - Finally,
PlotLabels
should be added to the bubble chart to identify each community (with different colors) and the definition of the directed linkages from/to the selected vertexV1
.
Manipulate[...]
be of the form so that once an input matrix is given, the bubble chart described above should be generated.
The above code shows what I could do so far.
EDIT
With the code by @Bob Hanlon, the bubble chart is generated by:
BubbleChart[
Association /@
GatherBy[Normal[<|Thread[vnames -> chartData]|>],
Position[cs, ToExpression[#[[1]]]][[1, 1]] &],
ChartLabels -> Automatic,
ChartStyle -> "Pastel",
ChartLegends->Placed[{"comm 1","comm 2","comm 3","comm 4"}, Below],
FrameLabel -> (Style[#, Bold] & /@ {"Cause", "Effect"}),
PlotTheme -> "Business",
PlotLabel->"Sector dominance, centrality, communities and neighborhood graph",
ImagePadding->{{Automatic, Automatic}, {Automatic, Scaled[.01]}},
ImageSize -> 375
]
I still need to map NeighborhoodGraph[wag, 4]
, for example, on top of the bubble chart by keeping the coordinates of vertices unchanged. Experiments with each vertex should be done by Manipulate[...]
.
vnames
is not defined. $\endgroup$BubbleChart[Association /@ GatherBy[Normal[<|Thread[vnames -> chartData]|>], Position[cs, ToExpression[#[[1]]]][[1, 1]] &], ChartLabels -> Automatic, FrameLabel -> (Style[#, Bold] & /@ {"Cause", "Effect"}), ImageSize -> 300]
I don't understand the rest of the question. $\endgroup$NeighborhoodGraph[wag, 4]
on to the bubble chart by keeping the positions of vertices in the bubble chart fixed. UsingManipulate
would be preferable to repeat the same plotting for each one of the vertices in the bubble chart. $\endgroup$