Skip to content

Commit

Permalink
Revert "Add closeness_centrality app and test case of duplicated mode…
Browse files Browse the repository at this point in the history
… modification (alibaba#336)"

This reverts commit 6a98c7e.
  • Loading branch information
acezen committed Jun 4, 2021
1 parent 336ec94 commit e925b46
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 677 deletions.
143 changes: 0 additions & 143 deletions analytical_engine/apps/centrality/closeness/closeness_centrality.h

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ limitations under the License.
#include "apps/centrality/eigenvector/eigenvector_centrality_context.h"

#include "core/app/app_base.h"
#include "core/utils/app_utils.h"
#include "core/worker/default_worker.h"

namespace gs {
Expand Down Expand Up @@ -110,12 +109,7 @@ class EigenvectorCentrality
for (auto& v : inner_vertices) {
auto es = frag.GetIncomingAdjList(v);
for (auto& e : es) {
double edata = 1.0;
static_if<!std::is_same<edata_t, grape::EmptyType>{}>(
[&](auto& e, auto& data) {
data = static_cast<double>(e.get_data());
})(e, edata);
x[v] += x_last[e.get_neighbor()] * edata;
x[v] += x_last[e.get_neighbor()] * e.get_data();
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions analytical_engine/apps/centrality/katz/katz_centrality.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ limitations under the License.
#include "apps/centrality/katz/katz_centrality_context.h"

#include "core/app/app_base.h"
#include "core/utils/app_utils.h"
#include "core/worker/default_worker.h"

namespace gs {
Expand Down Expand Up @@ -105,12 +104,7 @@ class KatzCentrality : public AppBase<FRAG_T, KatzCentralityContext<FRAG_T>>,
x[v] = 0;
for (auto& e : es) {
// do the multiplication y^T = Alpha * x^T A - Beta
double edata = 1.0;
static_if<!std::is_same<edata_t, grape::EmptyType>{}>(
[&](auto& e, auto& data) {
data = static_cast<double>(e.get_data());
})(e, edata);
x[v] += x_last[e.get_neighbor()] * edata;
x[v] += x_last[e.get_neighbor()] * e.get_data();
}
x[v] = x[v] * ctx.alpha + ctx.beta;
messages.SendMsgThroughEdges(frag, v, ctx.x[v]);
Expand Down
9 changes: 1 addition & 8 deletions analytical_engine/apps/projected/sssp_projected.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "grape/grape.h"

#include "core/app/app_base.h"
#include "core/utils/app_utils.h"
#include "core/worker/default_worker.h"

namespace gs {
Expand Down Expand Up @@ -70,7 +69,6 @@ class SSSPProjected : public AppBase<FRAG_T, SSSPProjectedContext<FRAG_T>> {
INSTALL_DEFAULT_WORKER(SSSPProjected<FRAG_T>, SSSPProjectedContext<FRAG_T>,
FRAG_T)
using vertex_t = typename fragment_t::vertex_t;
using edata_t = typename fragment_t::edata_t;

private:
// sequential Dijkstra algorithm for SSSP.
Expand All @@ -95,12 +93,7 @@ class SSSPProjected : public AppBase<FRAG_T, SSSPProjectedContext<FRAG_T>> {
for (auto& e : es) {
v = e.neighbor();
distv = ctx.partial_result[v];
double edata = 1.0;
static_if<!std::is_same<edata_t, grape::EmptyType>{}>(
[&](auto& e, auto& data) {
data = static_cast<double>(e.get_data());
})(e, edata);
ndistv = distu + edata;
ndistv = distu + e.data();
if (distv > ndistv) {
ctx.partial_result[v] = ndistv;
if (frag.IsInnerVertex(v)) {
Expand Down
14 changes: 2 additions & 12 deletions analytical_engine/apps/sssp/sssp_average_length.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ limitations under the License.
#include "grape/grape.h"

#include "core/app/app_base.h"
#include "core/utils/app_utils.h"
#include "core/worker/default_worker.h"
#include "sssp/sssp_average_length_context.h"

Expand All @@ -50,7 +49,6 @@ class SSSPAverageLength
grape::LoadStrategy::kBothOutIn;
using vertex_t = typename fragment_t::vertex_t;
using vid_t = typename fragment_t::vid_t;
using edata_t = typename fragment_t::vid_t;
// vertex msg: [source, v, sssp_length]
// OR sum msg: [fid, fid, sssp_length_sum]
using tuple_t = typename std::tuple<vid_t, vid_t, double>;
Expand Down Expand Up @@ -196,11 +194,7 @@ class SSSPAverageLength
for (auto& e : oes) {
auto u = e.get_neighbor();
if (frag.IsOuterVertex(u)) {
double v_u = 1.0;
static_if<!std::is_same<edata_t, grape::EmptyType>{}>(
[&](auto& e, auto& data) {
data = static_cast<double>(e.get_data());
})(e, v_u);
double v_u = (ctx.weight) ? e.get_data() : 1;
double dist = ctx.path_distance[v][src_vid] + v_u;
vid_t u_vid = frag.Vertex2Gid(u);
messages.SendToFragment(
Expand Down Expand Up @@ -245,11 +239,7 @@ class SSSPAverageLength
for (auto& e : oes) {
auto u = e.get_neighbor();
if (frag.IsInnerVertex(u)) {
double v_u = 1.0;
static_if<!std::is_same<edata_t, grape::EmptyType>{}>(
[&](auto& e, auto& data) {
data = static_cast<double>(e.get_data());
})(e, v_u);
double v_u = (ctx.weight) ? e.get_data() : 1;
updateVertexState(u, src_vid, dist_v + v_u, ctx);
}
}
Expand Down
5 changes: 4 additions & 1 deletion analytical_engine/apps/sssp/sssp_average_length_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class SSSPAverageLengthContext : public TensorContext<FRAG_T, double> {
explicit SSSPAverageLengthContext(const FRAG_T& fragment)
: TensorContext<FRAG_T, double>(fragment) {}

void Init(grape::DefaultMessageManager& messages) {
void Init(grape::DefaultMessageManager& messages, bool w) {
auto& frag = this->fragment();

weight = w;
inner_sum = 0.0;
path_distance.Init(frag.InnerVertices());
updated.Init(frag.InnerVertices());
Expand Down Expand Up @@ -71,6 +72,8 @@ class SSSPAverageLengthContext : public TensorContext<FRAG_T, double> {
#endif
}

bool weight;

// length sum of each fragment, only maintained by frag 0
std::map<fid_t, double> all_sums;

Expand Down
12 changes: 4 additions & 8 deletions analytical_engine/apps/sssp/sssp_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ limitations under the License.
#include "grape/grape.h"

#include "core/app/app_base.h"
#include "core/utils/app_utils.h"
#include "core/worker/default_worker.h"
#include "sssp/sssp_path_context.h"

Expand All @@ -49,7 +48,6 @@ class SSSPPath : public AppBase<FRAG_T, SSSPPathContext<FRAG_T>>,
grape::LoadStrategy::kBothOutIn;
using vertex_t = typename fragment_t::vertex_t;
using vid_t = typename fragment_t::vid_t;
using edata_t = typename fragment_t::edata_t;
using pair_msg_t = typename std::pair<vid_t, double>;

void PEval(const fragment_t& frag, context_t& ctx,
Expand Down Expand Up @@ -151,12 +149,10 @@ class SSSPPath : public AppBase<FRAG_T, SSSPPathContext<FRAG_T>>,
for (auto& e : oes) {
auto u = e.get_neighbor();
double new_distu;
double edata = 1.0;
static_if<!std::is_same<edata_t, grape::EmptyType>{}>(
[&](auto& e, auto& data) {
data = static_cast<double>(e.get_data());
})(e, edata);
new_distu = ctx.path_distance[v] + edata;
if (ctx.weight)
new_distu = ctx.path_distance[v] + e.get_data();
else
new_distu = ctx.path_distance[v] + 1;
if (frag.IsOuterVertex(u)) {
messages.SyncStateOnOuterVertex<fragment_t, pair_msg_t>(
frag, u, std::make_pair(v_vid, new_distu));
Expand Down
4 changes: 3 additions & 1 deletion analytical_engine/apps/sssp/sssp_path_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ class SSSPPathContext : public TensorContext<FRAG_T, typename FRAG_T::oid_t> {
explicit SSSPPathContext(const FRAG_T& fragment)
: TensorContext<FRAG_T, typename FRAG_T::oid_t>(fragment) {}

void Init(grape::DefaultMessageManager& messages, oid_t source) {
void Init(grape::DefaultMessageManager& messages, oid_t source, bool w) {
auto& frag = this->fragment();

source_id = source;
weight = w;
predecessor.Init(frag.InnerVertices());
path_distance.Init(frag.InnerVertices(),
std::numeric_limits<double>::max());
Expand Down Expand Up @@ -67,6 +68,7 @@ class SSSPPathContext : public TensorContext<FRAG_T, typename FRAG_T::oid_t> {
}

oid_t source_id;
bool weight;

typename FRAG_T::template vertex_array_t<vertex_t> predecessor;
typename FRAG_T::template vertex_array_t<double> path_distance;
Expand Down
Loading

0 comments on commit e925b46

Please sign in to comment.