Complex networks

Hugo Touchette
National Institute for Theoretical Physics (NITheP)
Stellenbosch, South Africa

Started: 4 August 2015
Last updated: 5 August 2015

Export directory

SetDirectory["~/archive/cours/outreach/networks/mathematica"]

Regular graphs

Complete graphs

Table[CompleteGraph[i],{i,2,10,2}]

Other regular graphs

CompleteGraph[6]

StarGraph[6]

CycleGraph[6]

CirculantGraph[10,{2,4}]

Random graphs

Examples

Table[RandomGraph[BernoulliGraphDistribution[6,0.5]],{4}]

Table[RandomGraph[BernoulliGraphDistribution[20,0.4]],{4}]

Table[RandomGraph[BernoulliGraphDistribution[n,0.5]],{n,{25,50}}]

Degre distribution

g1=RandomGraph[BernoulliGraphDistribution[10,0.5]]

VertexDegree[g1]

EdgeCount[g1]

pf1=Histogram[VertexDegree[g1],{1},PlotTheme->"Classic"]

Export["randomgraph0degdist.pdf",pf1]

Poisson distribution

pf2=With[{nvert=1000},
p=0.8/nvert;
g=RandomGraph[BernoulliGraphDistribution[nvert,p]];
degseq=VertexDegree[g];
p1=Histogram[degseq,Automatic,"Probability",PlotTheme->"Classic"];
p2=DiscretePlot[PDF[PoissonDistribution[nvert p],x],{x,0,10},Joined->True,Filling->None];
GraphicsRow[{Show[g],Show[p1,p2]}]
]

Export["randomgraphdist2.pdf",pf2]

Small world graphs

Table[RandomGraph[WattsStrogatzGraphDistribution[100,p,2]],{p,{0,0.1,1}}]

Scale-free graphs

gsf1=With[{},
g=RandomGraph[BarabasiAlbertGraphDistribution[200,2]];
sg=Part[VertexList[g],Ordering[VertexDegree[g],-5]];
HighlightGraph[g,sg]
]

pf3=With[{nvert=10^4},
g=RandomGraph[BarabasiAlbertGraphDistribution[nvert,2]];
dist=EmpiricalDistribution[VertexDegree[g]];
p1=ListLogLogPlot[Table[{k,PDF[dist,k]},{k,1,30}]];
p2=LogLogPlot[4/(k^2.7),{k,1,30},PlotStyle->{Red}];
Show[p1,p2]
]

Export["scalefreedist1.pdf",pf3]

Centrality

From the Mathematica document center.

g=ExampleData[{"NetworkGraph","ZacharyKarateClub"}];

Part[VertexList[g],Ordering[BetweennessCentrality[g],-5]]

HighlightGraph[g,%]