Changeset - 1df09cbbb7ed
[Not reviewed]
0 1 0
Tom Bannink - 8 years ago 2017-06-02 21:18:51
tom.bannink@cwi.nl
Fix DSP computation
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
cpp/switchchain_dsp.cpp
Show inline comments
 
@@ -56,49 +56,49 @@ class SwitchChain {
 
        return g.exchangeEdges(e1index, e2index, switchType);
 
    }
 

	
 
    Graph g;
 
    std::mt19937 mt;
 
    std::uniform_int_distribution<> edgeDistribution;
 
    //std::uniform_int_distribution<> permutationDistribution;
 
    std::bernoulli_distribution permutationDistribution;
 
};
 

	
 
double getProperty(const DegreeSequence& ds) {
 
    std::vector<std::vector<double>> vals(ds.size());
 
    for (auto& v : vals) {
 
        v.resize(ds.size(), 0);
 
    }
 

	
 
    auto D = 0u;
 
    for (auto d : ds)
 
        D += d;
 

	
 
    double factor = 1.0 / double(D);
 

	
 
    for (auto i = 0u; i < ds.size(); ++i) {
 
        for (auto j = i + 1; j < ds.size(); ++j) {
 
            vals[i][j] = 1.0 - std::exp(-ds[i] * ds[j] * factor);
 
            vals[i][j] = 1.0 - std::exp(-(ds[i] * ds[j] * factor));
 
        }
 
    }
 

	
 
    double result = 0.0;
 
    for (auto i = 0u; i < ds.size(); ++i) {
 
        for (auto j = i + 1; j < ds.size(); ++j) {
 
            for (auto k = j + 1; k < ds.size(); ++k) {
 
                result += vals[i][j] * vals[j][k] * vals[i][k];
 
            }
 
        }
 
    }
 
    return result;
 
}
 

	
 
int main() {
 
    // Generate a random degree sequence
 
    std::mt19937 rng(std::random_device{}());
 

	
 
    // Goal:
 
    // Degrees follow a power-law distribution with some parameter tau
 
    // Expect:  #tri = const * n^{ something }
 
    // The goal is to find the 'something' by finding the number of triangles
 
    // for different values of n and tau
 
    float tauValues[] = {2.1f, 2.5f, 2.9f};
0 comments (0 inline, 0 general)