Rich[G_,k_]:=Take[Sort[VertexList[G],VertexDegree[G][[Position[VertexList[G],#1][[1]][[1]]]]>VertexDegree[G][[Position[VertexList[G],#2][[1]][[1]]]]&],k]

SetDirectory[NotebookDirectory[]];

edges = Import["dblp_edges_maxAuthor20_simple_degree_1000_edges_v1.csv","HeaderLines"-> 4];

nodes = Import["dblp_nodes_maxAuthor20_simple_degree_1000_nodes_v1.csv","HeaderLines"-> 4];

DBLPVertex =nodes[[All,1]];

Length[DBLPVertex]

Length[edges]

DBLPedges  = Table[edges[[i]][[1]]\[UndirectedEdge]edges[[i]][[2]],{i,Length[edges]}];

(* import vertex color *)

Vcolor = Import["Vcolor_simple_v1.m"];

(* or read them form dictionary and find them *)

gender = Import["dblp_id_gender_dict_v1.csv"];

Vcolor = Table[DBLPVertex[[i]]-> If[gender[[Position[gender,DBLPVertex[[i]]][[1]][[1]]]][[2]]=="m",Blue,If[gender[[Position[gender,DBLPVertex[[i]]][[1]][[1]]]][[2]]=="f",Red,None]],{i,1,Length[DBLPVertex]}];

Length[Vcolor]

Export["Vcolor_simple_v1.m",Vcolor];

dblpG= Graph[DBLPVertex,DBLPedges,VertexStyle -> Vcolor]

BCdblp = BetweennessCentrality[dblpG];

Gsize = Table[VertexList[dblpG][[i]]-> {"Scaled",0.01 + BCdblp[[i]]/(100*EdgeCount[dblpG])},{i,1,VertexCount[dblpG]}];

dblpG1 =Subgraph[dblpG,ConnectedComponents[dblpG][[1]],VertexStyle -> Vcolor,VertexSize -> Gsize]

Export["DBLPtop1005.pdf",dblpG1]

VertexCount[dblpG1]

EdgeCount[dblpG1]

blue=VertexList[dblpG1,_?(PropertyValue[{dblpG1,#},VertexStyle]==Blue&)];

red=VertexList[dblpG1,_?(PropertyValue[{dblpG1,#},VertexStyle]==Red&)];

MaleG = Subgraph[dblpG1,blue,VertexStyle -> Vcolor,VertexSize -> Gsize];

VertexCount[MaleG]

FemaleG = Subgraph[dblpG1,red,VertexStyle -> Vcolor,VertexSize -> Gsize]

Export["DBLPtop135female.pdf",FemaleG]

VertexCount[FemaleG]

Length[ConnectedComponents[FemaleG]]

EdgeCount[FemaleG]

M135 =Subgraph[MaleG, Rich[MaleG,134],VertexStyle -> Vcolor,VertexSize -> Gsize, GraphLayout->"SpringElectricalEmbedding"]

Export["DBLPtop135male.pdf",M135]

EdgeCount[M135]

Length[ConnectedComponents[M135]]

femB = Sort[Join [Table[0,{Length[blue]-Length[red]}],BetweennessCentrality[dblpG1][[Flatten[Table[Position[VertexList[dblpG1],red[[i]]],{i,Length[red]}]]]]]];

maleB =Sort[BetweennessCentrality[dblpG1][[Flatten[Table[Position[VertexList[dblpG1],blue[[i]]],{i,Length[blue]}]]]]];

PairedBarChart[{maleB},{femB},ChartLabels->{Placed[{Style["Male",14],Style["Female",14]},Above],None,None},ChartStyle->{{Blue,Red},{EdgeForm[]},None,None},BarSpacing->{500,0,0}]

femB135 = Sort[BetweennessCentrality[dblpG1][[Flatten[Table[Position[VertexList[dblpG1],red[[i]]],{i,Length[red]}]]]]];

Length[femB135]

maleB135 =maleB[[Range[Length[blue]-134,Length[blue]]]];

Length[maleB135]

PairedBarChart[{maleB135},{femB135},ChartLabels->{Placed[{Style["Male",14],Style["Female",14]},Above],None,None},ChartStyle->{{Blue,Red},{EdgeForm[]},None,None},BarSpacing->{500,0,0}]

Export["DBLPtopBetweenness135.pdf",Out[65]]