Changeset - a410aaa16af7
[Not reviewed]
0 3 0
Tom Bannink - 8 years ago 2017-07-03 14:37:10
tombannink@gmail.com
Remove spectrum computation from canonical switchchain
3 files changed with 28 insertions and 28 deletions:
0 comments (0 inline, 0 general)
cpp/graph_powerlaw.hpp
Show inline comments
 
@@ -15,13 +15,10 @@ void generatePowerlawGraph(int n, float tau, Graph& g, DegreeSequence& ds,
 
    for (int i = 1;; ++i) {
 
        std::generate(ds.begin(), ds.end(),
 
                      [&degDist, &rng] { return degDist(rng); });
 
        // First make the sum even
 
        // First check if the sum is even
 
        unsigned int sum = std::accumulate(ds.begin(), ds.end(), 0);
 
        if (sum % 2) {
 
        if (sum % 2)
 
            continue;
 
            // Can we do this: ??
 
            ds.back()++;
 
        }
 

	
 
        if (g.createFromDegreeSequence(ds))
 
            break;
 
@@ -41,10 +38,8 @@ void generateCanonicalPowerlawGraph(int n, float tau, Graph &g,
 
    degDist.getFixedDistribution(n, ds.begin());
 

	
 
    unsigned int sum = std::accumulate(ds.begin(), ds.end(), 0);
 
    if (sum % 2) {
 
        //TODO: Can we do this: ??
 
    if (sum % 2)
 
        ds.back()++;
 
    }
 

	
 
    if (g.createFromDegreeSequence(ds))
 
        return;
cpp/switchchain_canonical_properties.cpp
Show inline comments
 
@@ -78,7 +78,8 @@ int main(int argc, char* argv[]) {
 
    outfile << "2: avgTriangles\n";
 
    outfile << "3: edges\n";
 
    outfile << "4: dstn\n";
 
    outfile << "5: { HH A, HH L, average A, average L }  where for each there is (average of) {lambda1 , lambda1 - lambda2, lambda1/lambda2}\n";
 
    //outfile << "5: { HH A, HH L, average A, average L }  where for each there is (average of) {lambda1 , lambda1 - lambda2, lambda1/lambda2}\n";
 
    outfile << "5: empty\n";
 
    outfile << "6: switching successrate after mixing\n";
 
    outfile << "7: initial HH triangles\n";
 
    outfile << "*)" << std::endl;
 
@@ -127,10 +128,12 @@ int main(int argc, char* argv[]) {
 
            GraphSpectrum gs_start(g);
 
            GraphSpectrum gs(chain.g);
 

	
 
            HHAspectrum =
 
                getSpectralValues(gs_start.computeAdjacencySpectrum());
 
            HHLspectrum =
 
                getSpectralValues(gs_start.computeLaplacianSpectrum());
 
            HHAspectrum.fill(0);
 
            HHLspectrum.fill(0);
 
            //HHAspectrum =
 
            //    getSpectralValues(gs_start.computeAdjacencySpectrum());
 
            //HHLspectrum =
 
            //    getSpectralValues(gs_start.computeLaplacianSpectrum());
 

	
 
            long long trianglesTotal = 0;
 
            int movesDone = 0;
 
@@ -141,12 +144,12 @@ int main(int argc, char* argv[]) {
 
                    if (chain.doMove())
 
                        ++movesDone;
 
                trianglesTotal += chain.g.countTriangles();
 
                auto sA = getSpectralValues(gs.computeAdjacencySpectrum());
 
                auto sL = getSpectralValues(gs.computeLaplacianSpectrum());
 
                for (auto i = 0u; i < 3; ++i) {
 
                    avgAspectrum[i] += sA[i];
 
                    avgLspectrum[i] += sL[i];
 
                }
 
                //auto sA = getSpectralValues(gs.computeAdjacencySpectrum());
 
                //auto sL = getSpectralValues(gs.computeLaplacianSpectrum());
 
                //for (auto i = 0u; i < 3; ++i) {
 
                //    avgAspectrum[i] += sA[i];
 
                //    avgLspectrum[i] += sL[i];
 
                //}
 
            }
 
            float avgTriangles = float(trianglesTotal) / float(measurements);
 
            float successrate =
 
@@ -156,7 +159,7 @@ int main(int argc, char* argv[]) {
 
            for (auto &f : avgLspectrum)
 
                f /= float(measurements);
 

	
 
            std::cout << "Measuring done." << std::flush;
 
            std::cout << "Measuring done. " << std::flush;
 

	
 
            if (outputComma)
 
                outfile << ',' << '\n';
 
@@ -166,11 +169,12 @@ int main(int argc, char* argv[]) {
 
            outfile << ',' << avgTriangles;
 
            outfile << ',' << g.edgeCount();
 
            outfile << ',' << getDSTN(ds);
 
            outfile << ',' << '{' << HHAspectrum;
 
            outfile << ',' << HHLspectrum;
 
            outfile << ',' << avgAspectrum;
 
            outfile << ',' << avgLspectrum;
 
            outfile << '}';
 
            outfile << ",{}";
 
            //outfile << ',' << '{' << HHAspectrum;
 
            //outfile << ',' << HHLspectrum;
 
            //outfile << ',' << avgAspectrum;
 
            //outfile << ',' << avgLspectrum;
 
            //outfile << '}';
 
            outfile << ',' << successrate;
 
            outfile << ',' << g.countTriangles();
 
            outfile << '}' << std::flush;
triangle_exponent_plots.m
Show inline comments
 
@@ -88,12 +88,13 @@ Show[ListPlot[{averagesExponents,mediansExponents},Joined->True,PlotMarkers->Aut
 
(*T(\[Tau]) including error bars*)
 

	
 

	
 
(* For visual, shift the tau values slightly left or right to distinguish the two datasets *)
 
tauValues=averagesGrouped[[All,1,1,1,2]];
 
averagesExponentsErrorBars=Map[{{#[[1]],#[[2]]["BestFitParameters"][[2]]},ErrorBar[#[[2]]["ParameterConfidenceIntervals"][[2]]-#[[2]]["BestFitParameters"][[2]]]}&,
 
Transpose[{tauValues,averagesFitsExtra}]];
 
Transpose[{tauValues-0.005,averagesFitsExtra}]];
 
mediansExponentsErrorBars=Map[{{#[[1]],#[[2]]["BestFitParameters"][[2]]},ErrorBar[#[[2]]["ParameterConfidenceIntervals"][[2]]-#[[2]]["BestFitParameters"][[2]]]}&,
 
Transpose[{tauValues+0.01,mediansFitsExtra}]];
 
plot2=Show[ErrorListPlot[{averagesExponentsErrorBars,mediansExponentsErrorBars},Joined->True,PlotMarkers->Automatic,Frame->True,FrameLabel->{"tau","triangle exponent"},PlotRange->{{2,3},{0,1.6}},ImageSize->300],Plot[3/2(3-tau),{tau,2,3},PlotStyle->{Dashed}]]
 
Transpose[{tauValues+0.005,mediansFitsExtra}]];
 
plot4=Show[ErrorListPlot[{averagesExponentsErrorBars,mediansExponentsErrorBars},Joined->True,PlotMarkers->Automatic,Frame->True,FrameLabel->{"tau","triangle exponent"},PlotRange->{{2,3},{0,1.6}},ImageSize->300],Plot[3/2(3-tau),{tau,2,3},PlotStyle->{Dashed}]]
 

	
 

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