So I tried
SyrianGovernment = {"Al-Safira"};
FSA = {"Atarib"};
ISIS = {"Al-Bab","Dayr Hafir","Jarabulus", "Manbij"};
YPG = {"Afrin","Ayn Al-Arab"};
Contested = {"South Mount Simeon", "North Mount Simeon", "Aleppo", "Azaz"};
vs = Join @@ MapThread[Thread[#1 -> #2] &, {{SyrianGovernment, FSA, ISIS, YPG},
{Red, Green, Black, Yellow, Gray}}];
mm = RandomChoice[{0, 1}, {65, 65}];
AdjacencyGraph[mm, VertexSize -> 0.4, VertexStyle -> vs]
I'm sure you can see what I'm trying to do here (I'm trying to colour the vertices or nodes of a Graph
). I'm trying to colour my Graph
four colours depending on what group they're in. I'd also like to know if I can program it such that nodes which I do not name can be coloured a certain colour as the rest.
This works:
SyrianGovernment = {"Al-Safira", "Al-Nabk", "Qatana", "Al-Qutayfah", "Al-Tall","Yabrud", "Zabadani", "Izra", "Al-Sanamayn"};FSA = {"Atarib", "South Mount Simeon", "Abu Kamal", "Mayadin"};ISIS = {"Al-Bab", "Dayr Hafir", "Jarabulus", "Manbij"};YPG = {"Afrin", "Ayn Al-Arab"};Contested = {"South Mount Simeon", "North Mount Simeon", "Aleppo","Azaz", "Darayya", "Duma", "Qudsaya", "Markaz Rif Dimashq","Daraa", "Deir ez-Zor"};
SeedRandom@5;
list = Flatten[{SyrianGovernment, FSA, ISIS, YPG, Contested}, 1];
vs = Flatten[MapThread[Thread[Rule[#1, #2]] &, {{_, SyrianGovernment, FSA, ISIS,YPG}, {Gray, Red, Green, Black, Yellow}}], 1];
g = Graph[(DirectedEdge @@@ DeleteDuplicates@RandomChoice[list, {65, 2}]), VertexSize -> .5,VertexLabels -> "Name", ImagePadding -> 20, VertexStyle -> vs]
But when I add say "Hama"
to SyrianGovernment
(or anything more for that matter), the graphic disappears.
So this doesn't work:
SyrianGovernment = {"Al-Safira", "Al-Nabk", "Qatana", "Al-Qutayfah", "Al-Tall","Yabrud", "Zabadani", "Izra", "Al-Sanamayn","Hama"};FSA = {"Atarib", "South Mount Simeon", "Abu Kamal", "Mayadin"};ISIS = {"Al-Bab", "Dayr Hafir", "Jarabulus", "Manbij"};YPG = {"Afrin", "Ayn Al-Arab"};Contested = {"South Mount Simeon", "North Mount Simeon", "Aleppo","Azaz", "Darayya", "Duma", "Qudsaya", "Markaz Rif Dimashq","Daraa", "Deir ez-Zor"};
SeedRandom@5;
list = Flatten[{SyrianGovernment, FSA, ISIS, YPG, Contested}, 1];
vs = Flatten[MapThread[Thread[Rule[#1, #2]] &, {{_, SyrianGovernment, FSA, ISIS,YPG}, {Gray, Red, Green, Black, Yellow}}], 1];
g = Graph[(DirectedEdge @@@ DeleteDuplicates@RandomChoice[list, {65, 2}]), VertexSize -> .5,VertexLabels -> "Name", ImagePadding -> 20, VertexStyle -> vs]