Files
@ 5027d9d4aa05
Branch filter:
Location: AENC/switchchain/triangle_gcm_initial_analysis.m
5027d9d4aa05
4.8 KiB
application/vnd.wolfram.mathematica.package
Add new mixingtime method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | (* ::Package:: *)
Needs["ErrorBarPlots`"]
(* ::Section:: *)
(*Data import*)
gsraw=Import[NotebookDirectory[]<>"data/graphdata_ccm_initialtris.m"];
(* gsraw=SortBy[gsraw,{#[[1,1]]&,#[[1,2]]&}]; (* Sort by n and then by tau. The {} forces a *stable* sort because otherwise Mathematica sorts also on triangle count and other things. *) *)
gdata=gsraw;
(* Data format: *)
(* gdata[[ tau index , datatype index ]] *)
(* datatype index:
1: {n,tau}
2: {uniform triangle samples}
3: {CCMdu initial triangle samples} <-- CCMdu: get new highest degree vertex every time
4: {CCMd initial triangle samples} <-- CCMd: finish vertex completely
*)
(* ::Section:: *)
(*Greedy configuration model*)
(* ::Subsection:: *)
(*Distribution of initial #triangles for CCMd(u) compared to uniform triangle distribution*)
getHistogram[run_]:=Histogram[{run[[2]],run[[3]],run[[4]]},Automatic,"Probability",
ChartLegends->Placed[{"Uniform","CCMdu","CCMd"},Bottom],
ImageSize->250,
Frame->True,
FrameLabel->{"Triangles","Probability"},
PlotLabel->("n = "<>ToString[run[[1,1]]]<>", \[Tau] = "<>ToString[run[[1,2]]])
];
histograms=Map[getHistogram,gdata]
(* ::Subsubsection:: *)
(*Exporting plots*)
getHistogram[run_,bins_,plotrange_,tickDelta_,textpos_,bottomLegends_,bottomLabel_]:=Histogram[{run[[2]],run[[3]],run[[4]]},bins,"Probability",
ImageSize->250,
AspectRatio->4/14,
PlotRange->plotrange,
Frame->True,
FrameLabel->{If[bottomLabel,"Triangles",None],"Probability"},
FrameTicks->{{{#,NumberForm[#,{2,2}]}&/@Range[0,0.30,tickDelta],Automatic},{Automatic,Automatic}},
Epilog->Text["n = "<>ToString[run[[1,1]]]<>", \[Tau] = "<>ToString[run[[1,2]]],textpos],
ChartLegends->If[bottomLegends,Placed[{"Uniform","CCMdu","CCMd"},Top],None]
];
{h1,h2,h3}={
getHistogram[gdata[[1]],Automatic,{0,0.30} ,0.1 ,Scaled[{0.82,0.86}],True ,False],
getHistogram[gdata[[2]], {5},{0,0.15} ,0.05,Scaled[{0.82,0.86}],False,False],
getHistogram[gdata[[3]],Automatic,Automatic,0.05,Scaled[{0.82,0.86}],False,True]
};
plotgrid1=Column[{h1,h2,h3}]
Export[NotebookDirectory[]<>"plots/ccm_initialtris.pdf",plotgrid1]
(* ::Section:: *)
(*CCMu rates only*)
gsraw2=Import[NotebookDirectory[]<>"data/graphdata_ccm_constructionrate.m"];
(* gsraw=SortBy[gsraw,{#[[1,1]]&,#[[1,2]]&}]; (* Sort by n and then by tau. The {} forces a *stable* sort because otherwise Mathematica sorts also on triangle count and other things. *) *)
gdata2=GatherBy[gsraw2,{#[[1,2]]&,#[[1,1]]&}];
(* Data format: *)
(* gdata[[ tau index, n index, run index , datatype index ]] *)
(* datatype index:
1: {n,tau}
3: CCMdu construction rate <-- CCMdu: get new highest degree vertex every time
4: CCMd construction rate <-- CCMd: finish vertex completely
*)
successrates=gdata2[[All,All,All,2]]; (* New datafile *)
legends=Map["\[Tau] = "<>ToString[#[[1,1,2]]]<>" ; avg = "<>ToString[NumberForm[N[Mean[#[[All,2]]]],{4,4}]]&,gdata2,{2}];
successrates=Map[Clip[#,{0,0.99999}]&,successrates,{3}];
datasets={successrates[[1,1]], successrates[[2,1]], successrates[[3,1]]};
selectedLegends={legends[[1,1]],legends[[2,1]],legends[[3,1]]};
plot1=Histogram[datasets,{-0.025,1.025,0.05},"Probability",
PlotRange->{{0,1},{0,1}},
ChartStyle->Directive[FaceForm[Opacity[0.8]],EdgeForm[Thickness[0.001]]],
ImageSize->300,AxesOrigin->{0,0},
Frame->True,
FrameLabel->{"successrate of CCMdu construction\n(distribution over sampled degree sequences)","Probability"},
ChartLegends->Placed[selectedLegends,Center],
PlotLabel->"n = 1000"]
histogramlist = Map[Last[HistogramList[#,{-0.05,1.05,0.1},"Probability"]]&,datasets];
histogramlist = Transpose[histogramlist];
(* labels=ConstantArray["",Ceiling[1/0.05]];
labels[[2;;-1;;2]]=Map[ToString,Range[0.1,1,0.1]]; *)
labels=Map[ToString,Range[0,1,0.1]];
plot2=BarChart[histogramlist,
PlotRange->{All,{0,1}},
BarSpacing->{None,Medium},
ChartLabels->{labels,None},
ImageSize->300,AxesOrigin->{0,0},
Frame->True,
FrameLabel->{"successrate of CCMdu construction\n(distribution over sampled degree sequences)","Probability"},
ChartLegends->Placed[selectedLegends,Center],
PlotLabel->"n = 1000"]
plot3=SmoothHistogram[datasets,{0.01,"Gaussian"},"PDF",
PlotRange->{{0,1},All},
ImageSize->300,AxesOrigin->{0,0},
Frame->True,
FrameLabel->{"successrate of CCMdu construction\n(distribution over sampled degree sequences)","PDF"},
PlotLegends->Placed[selectedLegends,Center],
PlotLabel->"n = 1000"]
(*
Table[
SmoothHistogram[datasets,{0.01,weightKernel},"PDF",
PlotRange->{{0,1},All},
(*ChartStyle\[Rule]Directive[FaceForm[Opacity[0.5]],EdgeForm[Thickness[0.007]]],*)
ImageSize->300,AxesOrigin->{0,0},
Frame->True,
FrameLabel->{"successrate of CCMdu construction\n over sampled degree sequences","CDF"},
PlotLegends->Placed[selectedLegends,Center],
PlotLabel->"n = 1000"],{weightKernel,{"Biweight","Gaussian","Rectangular","Cosine","SemiCircle"}}]
*)
Export[NotebookDirectory[]<>"plots/ccm_construction_successrates.pdf",plot2]
|