Changeset - 91b906fd074a
[Not reviewed]
0 2 4
Tom Bannink - 8 years ago 2017-06-03 21:10:00
tombannink@gmail.com
Add successrate time evol and correlation plots
6 files changed with 138 insertions and 3 deletions:
0 comments (0 inline, 0 general)
plots/dsp_correlations.pdf
Show inline comments
 
binary diff not shown
plots/successrate_correlations.pdf
Show inline comments
 
new file 100644
 
binary diff not shown
plots/timeevol_22_successrate.pdf
Show inline comments
 
new file 100644
 
binary diff not shown
plots/timeevol_22_successrate_triangles.pdf
Show inline comments
 
new file 100644
 
binary diff not shown
triangle_dsp_correlation_plots.m
Show inline comments
 
@@ -11,25 +11,25 @@ gsraw=Import[NotebookDirectory[]<>"data/graphdata_dsp.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=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
 
(* Data format: *)
 
(* gdata[[ tau index, n index, run index , datatype index ]] *)
 
(* datatype index:
 
1: {n,tau}
 
2: avgtris
 
3: dsp
 
*)
 
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
 
taulabels=Map["tau = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
 
taulabels=Map["\[Tau] = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
 

	
 

	
 
(* ::Section:: *)
 
(*Plot triangle counts vs dsp*)
 

	
 

	
 
(* ::Subsection:: *)
 
(*Compute dsp from ds*)
 

	
 

	
 
getProperty[ds1_]:=Module[{ds,n=Length[ds1],tmp=ConstantArray[0,{Length[ds1],Length[ds1]}]},
 
ds=N[ds1/Sqrt[N[Total[ds1]]]]; (* scale degrees by 1/Sqrt[total] *)
 
@@ -46,25 +46,38 @@ Sum[tmp[[i,j-i]]*tmp[[j,k-j]]*tmp[[i,k-i]],{i,1,n-2},{j,i+1,n-1},{k,j+1,n}]
 

	
 
(* gdata[[ tau index, n index, run index , {ntau, #tris, ds} ]] *)
 
avgAndProp=ParallelMap[{getProperty[#[[3]]],Mean[#[[2,1;;-1]]]}&,gdata[[2,2,1;;100]]];
 

	
 

	
 
(* ::Subsection:: *)
 
(*Plot #trianges vs some degree-sequence-property*)
 

	
 

	
 
allPlots=Map[Show[
 
ListPlot[#[[All,{2,3}]],
 
AxesOrigin->{0,0},
 
Frame->True,FrameLabel->{"degree-sequence-property","average number of triangles"},
 
Frame->True,FrameLabel->{"average number of triangles","degree-sequence-property"},
 
AspectRatio->Automatic,
 
ImageSize->Automatic,
 
PlotLabel->"n = "<>ToString[#[[1,1,1]]]<>" , \[Tau] = "<>ToString[#[[1,1,2]]],
 
PlotStyle->Black
 
],Plot[x,{x,1,10000}]]
 
&,gdata,{2}]
 

	
 

	
 
combiPlot=Show[
 
ListLogLogPlot[gdata[[All,1,All,{3,2}]],
 
(*AxesOrigin->{0,0},*)
 
(*PlotRange\[Rule]{{0,3000},{0,3000}},*)
 
PlotRange->Automatic,
 
Frame->True,FrameLabel->{"degree-sequence-property","average number of triangles"},
 
AspectRatio->Automatic,
 
ImageSize->Automatic,
 
PlotLabel->"n = "<>ToString[gdata[[1,1]][[1,1,1]]],
 
PlotLegends->taulabels
 
],Plot[x,{x,1,10000},PlotStyle->Black]]
 

	
 

	
 
plotgrid=GraphicsRow[{GraphicsColumn[allPlots[[{1,2},1]]],allPlots[[3,1]]},Spacings->0,ImageSize->600]
 

	
 

	
 
Export[NotebookDirectory[]<>"plots/dsp_correlations.pdf",plotgrid]
 
Export[NotebookDirectory[]<>"plots/dsp_correlations.pdf",combiPlot]
triangle_successrate_correlation_plots.m
Show inline comments
 
new file 100644
 
(* ::Package:: *)
 

	
 
Needs["ErrorBarPlots`"]
 

	
 

	
 
(* ::Section:: *)
 
(*Plot successrate over time*)
 

	
 

	
 
gsraw=Import[NotebookDirectory[]<>"data/graphdata_successrates_timeevol.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=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
 
(* Data format: *)
 
(* gdata[[ tau index, n index, run index , datatype index ]] *)
 
(* datatype index:
 
1: {n,tau}
 
2: avgtris
 
3: successrate
 
*)
 
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
 
taulabels=Map["tau = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
 

	
 

	
 
TwoAxisPlot[{f_, g_},{plotrange1_,plotrange2_}] := 
 
Module[{fgraph, ggraph, frange, grange, fticks, gticks, manualRanges},
 
manualRanges={plotrange1,plotrange2};
 
{fgraph, ggraph} = 
 
MapIndexed[
 
ListPlot[#1, Axes -> True, Joined->True,ImageSize->300,
 
PlotRange->manualRanges[[#2[[1]]]],
 
DataRange->{0,measureSkip*maxTime}
 
(* PlotStyle -> ColorData[1][#2[[1]]] *)
 
] &, {f, g}];
 
{frange, grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[2]] & /@ {fgraph, ggraph};
 
fticks = N@FindDivisions[frange, 10]; 
 
gticks = Quiet@Transpose@{fticks, ToString[NumberForm[#, 2], StandardForm] & /@ Rescale[fticks, frange, grange]}; 
 
Show[fgraph, ggraph /. Graphics[graph_, s___] :> Graphics[GeometricTransformation[graph, RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s],
 
Axes -> False, Frame -> True,
 
(*FrameStyle -> {ColorData[1] /@ {1, 2}, {Automatic, Automatic}}, *)
 
FrameTicks -> {{fticks, gticks}, {Automatic, Automatic}}]]
 

	
 

	
 
(* Test of plot function *)
 
TwoAxisPlot[{gdata[[1,1,{1,3},2]],gdata[[1,1,{1,3},3]]},{{0,12000},{0,100}}]
 

	
 

	
 
MeanFilter
 

	
 

	
 
(* For export *)
 
selectedData=gdata[[2,1]][[{1,3,4,5}]];
 
measureSkip=100;
 
minCount=Min[Map[Min[#[[2]]]&,selectedData]];
 
maxCount=Max[Map[Max[#[[2]]]&,selectedData]];
 
maxCount=Max[Map[1.5*Max[#[[2,-100;;-1]]]&,selectedData]];
 
maxTime=Max[Map[Length[#[[2]]]&,selectedData]];
 
(* maxTime=Round[30000/measureSkip]; *)
 
skipPts=Max[1,Round[maxTime/5000]]; (* Plotting every point is slow. Plot only once per `skipPts` timesteps *)
 
maxTime=Round[50000/measureSkip];
 
coarseData=Map[#[[2,1;;maxTime;;skipPts]]&,selectedData];
 
coarseData2=Map[#[[3,1;;maxTime;;skipPts]]/100&,selectedData];
 
coarseData3=Map[MeanFilter[#[[3]],6]/100&,selectedData];
 
labels=Map["{n,tau} = "<>ToString[#[[1]]]&,selectedData]
 
TwoAxisPlot[{coarseData,coarseData2},{{0,maxCount},{0,1}}]
 
plotTimeEvol1=ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","number of triangles"},PlotLabel->"n = 1000, \[Tau]=2.2",ImageSize->300]
 
plotTimeEvol2=ListPlot[coarseData2,Joined->True,PlotRange->{0,1},DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","successrate"},PlotLabel->"n = 1000, \[Tau]=2.2",ImageSize->300,PlotStyle->Opacity[0.5]];
 
plotTimeEvol3=ListPlot[coarseData3,Joined->True,PlotRange->{0,1},DataRange->{0,measureSkip*maxTime}];
 
plotTimeEvol4=Show[plotTimeEvol2,plotTimeEvol3]
 
(* Map[ListPlot[#,Joined->True,PlotRange\[Rule]{minCount,maxCount},DataRange\[Rule]{0,maxTime}]&,coarseData] *)
 

	
 

	
 
Export[NotebookDirectory[]<>"plots/timeevol_22_successrate_triangles.pdf",plotTimeEvol1]
 
Export[NotebookDirectory[]<>"plots/timeevol_22_successrate.pdf",plotTimeEvol4]
 

	
 

	
 
(* ::Section:: *)
 
(*Plot #trianges vs some successrate*)
 

	
 

	
 
gsraw=Import[NotebookDirectory[]<>"data/graphdata_successrates.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=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
 
(* Data format: *)
 
(* gdata[[ tau index, n index, run index , datatype index ]] *)
 
(* datatype index:
 
1: {n,tau}
 
2: avgtris
 
3: successrate
 
*)
 
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
 
taulabels=Map["\[Tau] = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
 

	
 

	
 
allPlots=Map[Show[
 
ListPlot[#[[All,{3,2}]],
 
AxesOrigin->{0,0},
 
Frame->True,FrameLabel->{"successrate","average number of triangles"},
 
(*AspectRatio->Automatic,*)
 
PlotRange->{{0,1},Automatic},
 
ImageSize->Automatic,
 
PlotLabel->"n = "<>ToString[#[[1,1,1]]]<>" , \[Tau] = "<>ToString[#[[1,1,2]]],
 
PlotStyle->PointSize[0.0001]
 
],Plot[x,{x,1,10000}]]
 
&,gdata,{2}]
 

	
 

	
 
combiPlot=ListLogPlot[gdata[[{1,3,5,7,9},1,All,{3,2}]],
 
AxesOrigin->{0,0},
 
Frame->True,FrameLabel->{"successrate","average number of triangles"},
 
(*AspectRatio->Automatic,*)
 
PlotRange->Automatic,
 
ImageSize->300,
 
PlotLabel->"n = "<>ToString[gdata[[1,1]][[1,1,1]]],
 
PlotLegends->taulabels[[{1,3,5,7,9}]]
 
]
 

	
 

	
 
Export[NotebookDirectory[]<>"plots/successrate_correlations.pdf",combiPlot]
0 comments (0 inline, 0 general)