Graph of R package dependencies

Importing data

json=Import["/Users/blmayer/doctorate/visualizacao/exercises/packages.json"];

Transform

packages=#[[1]]->#[[2]]&@*Values/@json[[All,{1,2}]]

Filter

communities=FindGraphCommunities[packages];

community=Select[packages, Length[Intersection[#/.Rule->List,communities[[1]]]]>0&];

See

communities=FindGraphCommunities[packages];

n=12;
g=Graph[Select[packages, Length[Intersection[#/.Rule->List,communities[[n]]]]>0&], VertexLabels->"Name",DirectedEdges->False]

Exporting

hexString[color_]:=
"#"<>StringJoin[
StringPadLeft[IntegerString[IntegerPart[255color[[1]]],16],2,"0"],
StringPadLeft[IntegerString[IntegerPart[255color[[2]]],16],2,"0"],
StringPadLeft[IntegerString[IntegerPart[255color[[3]]],16],2,"0"]
]

Export[NotebookDirectory[]<>"matrix-"<>ToString[n]<>".json", AdjacencyMatrix[g]//Normal]

Export[NotebookDirectory[]<>"packages-"<>ToString[n]<>".csv",Join[{{"name", "color"}}, {#,hexString[RandomColor[]]}&/@VertexList[g]]]