Changeset - eba8261885e8
[Not reviewed]
master
0 1 0
Tom Bannink - 6 years ago 2019-02-27 16:38:05
tom.bannink@cwi.nl
Change trimeevol plot for thesis
1 file changed with 8 insertions and 3 deletions:
0 comments (0 inline, 0 general)
triangle_analysis.m
Show inline comments
 
(* ::Package:: *)
 

	
 
Quit[]
 

	
 

	
 
Needs["ErrorBarPlots`"]
 
Needs["MaTeX`"]
 

	
 

	
 
(* ::Section:: *)
 
(*TODO*)
 

	
 

	
 
(* ::Text:: *)
 
(*- Triangle law exponent: gather more data*)
 
(**)
 
(*- Why does GCM-2 start with very low #triangles*)
 
(*  Do not only consider number of standard deviations but also relative number of triangles.*)
 
(*  Look at the following: for all triangles (v1, v2, v3) consider the degrees d1<d2<d3 and make a scatter plot of di vs dj. Make such a scatter plot for the initial GCM-2 graph and for a mixed graph and see how it changes.*)
 
(**)
 
(*- GCM success rates: for the degree sequences where it "always fails", look at the degree sequence. Does it have a low/high number of degree 1 nodes? Is the maximum degree very low/high?*)
 
(**)
 
(*- Does GCM start closer to uniform?*)
 
(*   (a) How close to uniform ? At least w.r.t. the measure of #triangles*)
 
(*   (b) How often does this procedure work/fail. Might still be faster to do switchings from Erdos-Gallai.*)
 
(*   (d) Time evolution for GCM on top of Erdos-Gallai time evolution.*)
 
(**)
 
(*- Count #moves that result in +-k triangles (one move could create many triangles at once!)*)
 
(**)
 
(*- For a graph snapshot: for all V shapes, compute the number of ways to make it into a triangle:*)
 
(*  Let u1,u2 be the endpoints of the V. For all neighbors v1 of u1 and v2 of u2, see of v1,v2 has an edge. Meaning, if we were to select randomly an u1 edge and an u2 edge, then whats the probability that it can be used to switch the V into a triangle.*)
 
@@ -158,59 +159,63 @@ maxTime=Max[Map[Length[#[[2]]]&,selectedData]];
 
(* maxTime=30000; *)
 
skipPts=Max[1,Round[maxTime/500]]; (* Plotting every point is slow. Plot only once per `skipPts` timesteps *)
 
coarseData=Map[#[[2,1;;maxTime;;skipPts]]&,selectedData];
 
labels=Map["{n,tau} = "<>ToString[#[[1]]]&,selectedData];
 
ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},PlotLegends->labels]
 
(* Map[ListPlot[#,Joined->True,PlotRange\[Rule]{minCount,maxCount},DataRange\[Rule]{0,maxTime}]&,coarseData] *)
 

	
 

	
 
selectedData=gdata[[1,1]];
 
measureSkip=1;
 
minCount=Min[Map[Min[#[[2]]]&,selectedData]];
 
maxCount=Max[Map[Max[#[[2]]]&,selectedData]];
 
maxTime=Max[Map[Length[#[[2]]]&,selectedData]];
 
maxTime=30000;
 
skipPts=Max[1,Round[maxTime/100]]; (* Plotting every point is slow. Plot only once per `skipPts` timesteps *)
 
coarseData=Map[#[[2,1;;maxTime;;skipPts]]&,selectedData];
 
labels=Map["{n,tau} = "<>ToString[#[[1]]]&,selectedData];
 
plot1=ListPlot[coarseData[[1;;5]],Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime}]
 
plot2=ListPlot[coarseData[[6;;10]],Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime}]
 
plot3=ListPlot[coarseData[[11;;15]],Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime}]
 
plot4=ListPlot[coarseData[[16;;20]],Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime}]
 

	
 

	
 
(* For export *)
 
numPlots=20;
 
selectedData=gdata[[2,1]][[-numPlots;;-1]];
 
numPlots=25;
 
selectedPlots={6,7,8,11,12,13,16,17,18,21,22,23};
 
selectedData=gdata[[2,1]][[selectedPlots]];
 
measureSkip=1;
 
minCount=Min[Map[Min[#[[2]]]&,selectedData]];
 
maxCount=Max[Map[Max[#[[2]]]&,selectedData]];
 
maxTime=Max[Map[Length[#[[2]]]&,selectedData]];
 
(* maxTime=30000; *)
 
skipPts=Max[1,Round[maxTime/5000]]; (* Plotting every point is slow. Plot only once per `skipPts` timesteps *)
 
coarseData=Map[#[[2,1;;maxTime;;skipPts]]&,selectedData];
 
labels=Map["{n,tau} = "<>ToString[#[[1]]]&,selectedData];
 
plotTimeEvol=ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","number of triangles"},ImageSize->300]
 
plotTimeEvol=ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},
 
Frame->True,FrameLabel->{MaTeX["\\text{timesteps}"],MaTeX["\\text{number of triangles}"]},
 
PlotLabel->MaTeX["n=1000,\\; \\tau = 2.2"],
 
ImageSize->250]
 
(* Map[ListPlot[#,Joined->True,PlotRange\[Rule]{minCount,maxCount},DataRange\[Rule]{0,maxTime}]&,coarseData] *)
 

	
 

	
 
Export[NotebookDirectory[]<>"plots/timeevol.pdf",plotTimeEvol]
 

	
 

	
 
movingAvg=Map[MovingAverage[#[[2]],2000][[1;;-1;;skipPts]]-Mean[#[[2,-20000;;-1]]]&,selectedData[[1;;-1;;5]]];
 
plotMovingAvg=ListPlot[movingAvg,Joined->True,PlotRange->All,DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","number of triangles"}]
 

	
 

	
 
(* ::Subsection:: *)
 
(*Fit exponential to triangles time evolution*)
 

	
 

	
 
fitList=Map[NonlinearModelFit[#[[2]],Exp[-(t-t0)/tmix]+c,{{tmix,1000},{t0,10000},{c,2000}},t]&,selectedData];
 
(* tmix*Log[1/epsilon] gives the time it takes to get a factor epsilon close to the average *)
 
(* t0 gives the time it takes to be exactly 1 triangle (in absolute value) away from the average *)
 
(* Use fit["BestFitParameters"] to get parameters *)
 
(* Use fit[t] to get fit value *)
 
fitFuncsT=Map[#[t]&,fitList];
 
tmixList=Map[tmix/.#["BestFitParameters"]&,fitList];
 

	
 

	
 
timeplot1=ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},PlotStyle->Opacity[0.5]];
0 comments (0 inline, 0 general)