Changeset - 06fad9499398
[Not reviewed]
0 2 0
Tom Bannink - 8 years ago 2017-03-01 13:19:29
tombannink@gmail.com
Add TODO list to mathematica notebook
2 files changed with 24 insertions and 6 deletions:
0 comments (0 inline, 0 general)
cpp/showgraphs.m
Show inline comments
 
(* ::Package:: *)
 

	
 
Needs["ErrorBarPlots`"]
 

	
 

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

	
 

	
 
(* ::Text:: *)
 
(*- Compute  Sum over i<j<k  of  (1-Exp[- d_i d_j / (2E)]) * (1 - Exp[-d_j d_k / (2E)]) * (1 - Exp[-d_k d_i / (2E)]) .*)
 
(*   Only depends on degree sequence. Can be done with current data.*)
 
(*- Do a single very long run to see if there are any weird things after many steps*)
 
(*- Use different starting point for switch chain that is closer to uniform:*)
 
(*   Do configuration model, starting with the vertex with highest degree and keeping track of a "forbidden list" meaning dont pair something that is not allowed*)
 
(*   (a) How close is this 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.*)
 
(*- Improve runtime*)
 
(*   (a) Don't remove/add edges from the std::vector. Simply replace them*)
 
(*   (b) Better triangle counting? (I doubt it)*)
 
(*   (c) Do not choose the three permutations with 1/3 probability: choose the "staying" one with a very low probability. Should still be a valid switch chain?*)
 
(*- ?*)
 

	
 

	
 
(* ::Section:: *)
 
(*Visualize graphs*)
 

	
 

	
 
gsraw=Import[NotebookDirectory[]<>"graphdata.m"];
 

	
 
@@ -39,12 +58,13 @@ Export[NotebookDirectory[]<>"graphdata_merged_new.m",Join[mergedData,newData]]
 
(* ::Subsection:: *)
 
(*Plot empirical distribution of maximum degree*)
 

	
 

	
 
maxDegrees=Map[{#[[1]],Max[#[[3]]]}&,gsraw];
 
maxDegrees=GatherBy[maxDegrees,{#[[1,2]]&,#[[1,1]]&}];
 
(* maxDegrees[[ tau index, n index, run index,  ntau or dmax ]] *)
 

	
 

	
 
Histogram[maxDegrees[[1,-1,All,2]],PlotRange->{{0,2000},{0,100}},AxesLabel->{"d_max","frequency"}]
 
Histogram[maxDegrees[[2,-1,All,2]],PlotRange->{{0,2000},{0,100}},AxesLabel->{"d_max","frequency"}]
 
Histogram[maxDegrees[[3,-1,All,2]],PlotRange->{{0,2000},{0,100}},AxesLabel->{"d_max","frequency"}]
 

	
 
@@ -70,16 +90,14 @@ ListPlot[coarseData,Joined->True,PlotRange->{minCount,maxCount},DataRange->{0,ma
 

	
 

	
 
averages=Map[{#[[1]],Mean[#[[2,1;;-1]]]}&,gsraw];
 
(* Sort by n *)
 
averages=SortBy[averages,#[[1,1]]&];
 
(* Split by n,tau *)
 
averagesGrouped=GatherBy[averages,{#[[1,1]]&,#[[1,2]]&}];
 
(* averagesGroupes[[ n index, tau index , run index, {ntau, tri, ds} ]] *)
 
averagesGrouped=Transpose[averagesGrouped];
 
(* averagesGrouped[[ tau index, n index, run index ]] *)
 
averagesGrouped=GatherBy[averages,{#[[1,2]]&,#[[1,1]]&}];
 
(* averagesGrouped[[ tau index, n index, run index , {ntau, tri, ds} ]] *)
 
nlabels=Map["n = "<>ToString[#]&,averagesGrouped[[1,All,1,1,1]]];
 
taulabels=Map["tau = "<>ToString[#]&,averagesGrouped[[All,1,1,1,2]]];
 
averagesErrorBars=Map[
 
{{#[[1,1,1]],Mean[#[[All,2]]]},
 
ErrorBar[StandardDeviation[#[[All,2]]]/Sqrt[Length[#]]]
 
}&,averagesGrouped,{2}];
cpp/switchchain.cpp
Show inline comments
 
@@ -81,13 +81,13 @@ int main() {
 
    Graph g;
 

	
 
    std::ofstream outfile("graphdata.m");
 
    outfile << '{';
 
    bool outputComma = false;
 

	
 
    for (int numVertices = 2000; numVertices <= 10000; numVertices += 1000) {
 
    for (int numVertices = 4000; numVertices <= 8000; numVertices += 1000) {
 
        for (float tau : tauValues) {
 

	
 
            DegreeSequence ds(numVertices);
 
            powerlaw_distribution degDist(tau, 2, numVertices);
 
            //std::poisson_distribution<> degDist(12);
 

	
 
@@ -115,13 +115,13 @@ int main() {
 
                }
 

	
 
                std::cout << "Starting switch Markov chain with n = "
 
                          << numVertices << ", tau = " << tau << ". \t"
 
                          << std::flush;
 

	
 
                constexpr int mixingTime = 15000;
 
                constexpr int mixingTime = 20000;
 
                constexpr int measureTime = 10000;
 
                constexpr int measureSkip =
 
                    100; // Take a sample every 100 steps
 
                constexpr int measurements =
 
                    (measureTime - 1) / measureSkip + 1;
 
                int movesDone = 0;
0 comments (0 inline, 0 general)