(* ::Package:: *)

gsraw=Import[NotebookDirectory[]<>"data/graphdata_properties.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: avgTriangles
3: edges
4: dstn
5: { HH A, HH L, average A, average L }  where for each there is (average of) {lambda1 , lambda1 - lambda2, lambda1/lambda2}
6: switching successrate after mixing
7: initial HH triangles
*)
tauvalues=gdata[[All,1,1,1,2]];
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
taulabels=Map["\[Tau] = "<>ToString[#]&,gdata[[All,1,1,1,2]]];


histograms=Map[Histogram[#[[All,5,2,1]],{0,#[[1,1,1]],Automatic}]&,gdata,{2}];


TableForm[histograms,TableHeadings->{taulabels,nlabels}]


initialLaplacianData=gdata[[All,All,All,5,2]];
mixedLaplacianData=gdata[[All,All,All,5,4]];
lmaxDifference=Map[#[[5,2,1]]-#[[5,4,1]]&,gdata,{3}];
lmaxRatio=Map[#[[5,2,1]]/#[[5,4,1]]&,gdata,{3}];
lgapDifference=Map[#[[5,2,2]]-#[[5,4,2]]&,gdata,{3}];
lgapRatio=Map[#[[5,2,2]]/#[[5,4,2]]&,gdata,{3}];
lratioDifference=Map[#[[5,2,3]]-#[[5,4,3]]&,gdata,{3}];
lratioRatio=Map[#[[5,2,3]]/#[[5,4,3]]&,gdata,{3}];


Histogram[lmaxDifference[[1,1,All]]]
Histogram[lmaxRatio[[1,1,All]]]
Histogram[lgapDifference[[1,1,All]]]
Histogram[lgapRatio[[1,1,All]]]
Histogram[lratioDifference[[1,1,All]]]
Histogram[lratioRatio[[1,1,All]]]



