Skip to content

Commit

Permalink
Merge branch 'algoBranch' into newalgoBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
ncbd committed Aug 22, 2024
2 parents 9dc2f0e + f20f468 commit 4758a1f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions procedures/algo_cpp/bc_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re
// prepare
start_time = get_time();
size_t samples = 10;
std::string output_file = "";
try {
json input = json::parse(request);
parse_from_json(samples, "samples", input);
parse_from_json(output_file, "output_file", input);
} catch (std::exception& e) {
response = "json parse error: " + std::string(e.what());
std::cout << response << std::endl;
Expand All @@ -51,6 +53,9 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re

// output
start_time = get_time();
if (output_file != "") {
olapondb.WriteToFile<double>(score, output_file);
}
// TODO(any): write score back to graph
auto output_cost = get_time() - start_time;

Expand Down
6 changes: 6 additions & 0 deletions procedures/algo_cpp/clce_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/

#include <string>
#include "lgraph/olap_on_db.h"
#include "tools/json.hpp"
#include "./algo.h"
Expand All @@ -26,9 +27,11 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re
// prepare
start_time = get_time();
size_t samples = 64;
std::string output_file;
try {
json input = json::parse(request);
parse_from_json(samples, "samples", input);
parse_from_json(output_file, "output_file", input);
} catch (std::exception& e) {
response = "json parse error: " + std::string(e.what());
std::cout << response << std::endl;
Expand Down Expand Up @@ -62,6 +65,9 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re

// output
start_time = get_time();
if (output_file != "") {
olapondb.WriteToFile<double>(score, output_file);
}
auto output_cost = get_time() - start_time;

// return
Expand Down
7 changes: 7 additions & 0 deletions procedures/algo_cpp/pagerank_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,17 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re
printf("max rank value is pr[%ld] = %lf\n", olapondb.OriginalVid(max_pr_vi), pr[max_pr_vi]);
auto output_cost = get_time() - start_time;

auto vit = txn.GetVertexIterator(olapondb.OriginalVid(max_pr_vi), false);
auto vit_label = vit.GetLabel();
auto primary_field = txn.GetVertexPrimaryField(vit_label);
auto field_data = vit.GetField(primary_field);
// return
{
json output;
output["max_pr_id"] = olapondb.OriginalVid(max_pr_vi);
output["max_pr_label"] = vit_label;
output["max_pr_primaryfield"] = primary_field;
output["max_pr_fielddata"] = field_data.ToString();
output["max_pr_val"] = pr[max_pr_vi];
output["num_vertices"] = olapondb.NumVertices();
output["num_edges"] = olapondb.NumEdges();
Expand Down
5 changes: 5 additions & 0 deletions procedures/algo_cpp/trustrank_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re
std::vector<int64_t> trust_list = {0, 1, 3};
std::string label = "node";
std::string field = "id";
std::string output_file = "";

try {
json input = json::parse(request);
parse_from_json(iterations, "iterations", input);
parse_from_json(label, "label", input);
parse_from_json(field, "field", input);
parse_from_json(output_file, "output_file", input);
if (input["trust_list"].is_array()) {
trust_list.clear();
}
Expand Down Expand Up @@ -72,6 +74,9 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re
auto field_data = vit.GetField(primary_field);
// output
start_time = get_time();
if (output_file != "") {
olapondb.WriteToFile<double>(curr, output_file);
}
// TODO(any): write curr back to graph
auto output_cost = get_time() - start_time;

Expand Down

0 comments on commit 4758a1f

Please sign in to comment.