Skip to content

Commit

Permalink
Merge 6ff53fb into 78e186c
Browse files Browse the repository at this point in the history
  • Loading branch information
angriman committed Jul 15, 2019
2 parents 78e186c + 6ff53fb commit 07f3e56
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 165 deletions.
2 changes: 1 addition & 1 deletion extlibs/tlx
Submodule tlx updated 75 files
+5 −1 .travis.yml
+3 −0 CMakeLists.txt
+5 −4 README.md
+39 −24 appveyor.yml
+1 −1 misc/format/analyze-source.pl
+10 −3 tests/CMakeLists.txt
+5 −11 tests/algorithm/multiway_merge_benchmark.cpp
+39 −36 tests/container/btree_speedtest.cpp
+53 −46 tests/container/btree_speedtest.plot
+ tests/container/btree_speedtest_results.pdf
+3 −8 tests/container/d_ary_heap_speedtest.cpp
+46 −0 tests/container/d_ary_heap_test.cpp
+3 −0 tests/container/loser_tree_test.cpp
+143 −0 tests/container/splay_tree_test.cpp
+7 −0 tests/die_test.cpp
+85 −3 tests/math_test.cpp
+37 −0 tests/multi_timer_test.cpp
+166 −0 tests/sort_strings_parallel_test.cpp
+22 −339 tests/sort_strings_test.cpp
+354 −0 tests/sort_strings_test.hpp
+76 −16 tests/string_test.cpp
+3 −0 tests/thread_pool_test.cpp
+4 −0 tlx/CMakeLists.txt
+11 −0 tlx/cmdline_parser.cpp
+3 −0 tlx/cmdline_parser.hpp
+1 −0 tlx/container.hpp
+18 −15 tlx/container/btree.hpp
+69 −0 tlx/container/d_ary_addressable_int_heap.hpp
+61 −0 tlx/container/d_ary_heap.hpp
+7 −0 tlx/container/simple_vector.hpp
+348 −0 tlx/container/splay_tree.hpp
+34 −0 tlx/die.hpp
+3 −0 tlx/die/core.cpp
+67 −0 tlx/die/core.hpp
+30 −7 tlx/logger/core.cpp
+5 −1 tlx/logger/core.hpp
+5 −4 tlx/main.dox
+3 −0 tlx/math.hpp
+7 −0 tlx/math/clz.hpp
+154 −0 tlx/math/ctz.hpp
+1 −1 tlx/math/div_ceil.hpp
+6 −1 tlx/math/popcount.hpp
+44 −0 tlx/math/power_to_the.hpp
+35 −0 tlx/math/round_up.hpp
+153 −0 tlx/multi_timer.cpp
+142 −0 tlx/multi_timer.hpp
+14 −4 tlx/semaphore.hpp
+1 −0 tlx/sort.hpp
+0 −1 tlx/sort/strings.hpp
+1,521 −0 tlx/sort/strings/parallel_sample_sort.hpp
+728 −0 tlx/sort/strings/sample_sort_tools.hpp
+32 −2 tlx/sort/strings/string_ptr.hpp
+93 −0 tlx/sort/strings/string_set.hpp
+312 −0 tlx/sort/strings_parallel.hpp
+9 −1 tlx/string.hpp
+85 −0 tlx/string/bitdump.cpp
+92 −0 tlx/string/bitdump.hpp
+82 −21 tlx/string/ends_with.cpp
+28 −4 tlx/string/ends_with.hpp
+31 −0 tlx/string/format_iec_units.hpp
+2 −18 tlx/string/format_si_iec_units.hpp
+31 −0 tlx/string/format_si_units.hpp
+83 −0 tlx/string/hash_djb2.hpp
+82 −0 tlx/string/hash_sdbm.hpp
+3 −3 tlx/string/join_generic.hpp
+62 −0 tlx/string/ssprintf.cpp
+46 −0 tlx/string/ssprintf.hpp
+94 −0 tlx/string/ssprintf_generic.hpp
+49 −16 tlx/string/starts_with.cpp
+27 −3 tlx/string/starts_with.hpp
+33 −1 tlx/thread_pool.cpp
+12 −11 tlx/thread_pool.hpp
+25 −0 tlx/timestamp.cpp
+23 −0 tlx/timestamp.hpp
+1 −1 tlx/version.hpp
59 changes: 39 additions & 20 deletions include/networkit/centrality/TopCloseness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@

#ifndef TOPCLOSENESS_H_
#define TOPCLOSENESS_H_
#include <networkit/auxiliary/PrioQueue.hpp>

#include <memory>

#include <networkit/base/Algorithm.hpp>
#include <networkit/components/StronglyConnectedComponents.hpp>
#include <networkit/graph/Graph.hpp>

namespace NetworKit {

/**
* @ingroup centrality
*/
class TopCloseness : public Algorithm {
class TopCloseness final : public Algorithm {
public:
/**
* Finds the top k nodes with highest closeness centrality faster than
Expand Down Expand Up @@ -46,7 +49,7 @@ class TopCloseness : public Algorithm {
/**
* Computes top-k closeness on the graph passed in the constructor.
*/
void run();
void run() override;

/**
* Returns a list with the k nodes with highest closeness.
Expand All @@ -70,38 +73,53 @@ class TopCloseness : public Algorithm {
*/
std::vector<edgeweight> topkScoresList(bool includeTrail = false);

protected:
Graph G;
private:
const Graph &G;
count n;
count k;
bool first_heu, sec_heu;
std::vector<node> topk;
count visEdges = 0;
count n_op = 0;
count trail = 0;
double maxFarness = -1.f;
count nMaxFarness = 0;
std::vector<std::vector<node>> levels;
std::vector<count> nodesPerLev;
count nLevs = 0;
count visEdges;
count n_op;
count trail;
double maxFarness = -1.0;
count nMaxFarness;
std::vector<std::vector<count>> nodesPerLevs, sumLevels;
std::vector<edgeweight> topkScores;
std::vector<count> maxlevel;
std::vector<count> maxlevelSize;
std::vector<std::vector<count>> subtree;
std::vector<double> farness;
std::vector<count> reachL;
std::vector<count> reachU;
std::vector<count> component;

std::unique_ptr<StronglyConnectedComponents> sccsPtr;

void init();
double BFScut(node v, double x, bool *visited, count *distances, node *pred,
count *visEdges);
double BFScut(node v, double x, std::vector<bool> &visited, std::vector<count> &distances,
std::vector<node> &pred, count &visEdges);
void computelBound1(std::vector<double> &S);
void BFSbound(node x, std::vector<double> &S, count *visEdges,
void BFSbound(node x, std::vector<double> &S, count &visEdges,
const std::vector<bool> &toAnalyze);
void computeReachable();
void computeReachableNodesUndir();
void computeReachableNodesDir();

// Returns the node with highest farness
struct LargerFarness {
public:
LargerFarness(const std::vector<double> &v_) : v(v_) {}
bool operator()(node x, node y) const { return v[x] > v[y]; }

private:
const std::vector<double> &v;
};

struct SmallerFarness {
public:
SmallerFarness(const std::vector<double> &v_) : v(v_) {}
bool operator()(node x, node y) const { return v[x] < v[y]; }

private:
const std::vector<double> &v;
};
};

inline std::vector<node> TopCloseness::topkNodesList(bool includeTrail) {
Expand All @@ -122,6 +140,7 @@ inline std::vector<edgeweight> TopCloseness::topkScoresList(bool includeTrail) {
std::vector<double> topkScoresNoTrail(begin, begin + k);
return topkScoresNoTrail;
}

return topkScores;
}

Expand Down
Loading

0 comments on commit 07f3e56

Please sign in to comment.