大数据分析,同步图计算,三角形计数,graphlite

本文探讨了大数据分析中的同步图计算技术,重点关注了使用GraphLite进行三角形计数的方法。通过定义结构体存储统计结果,处理图输入和输出,以及理解Aggregator的输入类型和超步中的变量生命周期,可以实现高效的计算。同时,文中提到了迭代器的正确使用,特别是find和end函数的应用。
摘要由CSDN通过智能技术生成

大数据分析,同步图计算,三角形计数,graphlite

#题目要求
#代码实现
1.定义结构体存统计结果
2.图输入
3.结果输出(定义类外的变量以从计算函数类vertex传出结果)
4.对Aggregator的输入类型更改,涉及到对指针的使用https://blog.csdn.net/liu100m/article/details/90731422
5.计算函数注意超步中变量的存在周期,compute函数中的变量只存在于一个超步,新的超步会更新。用map函数在vertex类中存每个点的出边和入边
6.注意迭代器的使用,find函数,end函数;

#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>

#include "GraphLite.h"

#define VERTEX_CLASS_NAME(name) DirectedTriangleCount##name

#define EPS 1e-6
typedef struct result{
   
    int through_num;
    int cycle_num;
}RESULT;
class VERTEX_CLASS_NAME(InputFormatter): public InputFormatter {
   
        public:
        int64_t getVertexNum() {
   
            unsigned long long n;
            sscanf(m_ptotal_vertex_line, "%lld", &n);
            m_total_vertex= n;
            return m_total_vertex;
        }
        int64_t getEdgeNum() {
   
            unsigned long long n;
            sscanf(m_ptotal_edge_line, "%lld", &n);
            m_total_edge= n;
            return m_total_edge;
        }
        int getVertexValueSize() {
   
            m_n_value_size = sizeof(int);
            return m_n_value_size;
        }
        int getEdgeValueSize() {
   
            m_e_value_size = sizeof(int);
            return m_e_value_size;
        }
        int getMessageValueSize() {
   
            m_m_value_size = sizeof(int64_t);
            return m_m_value_size;
        }
        void loadGraph() {
   
            unsigned long long last_vertex;
            unsigned long long from;
            unsigned long long to;
            int weight = 0;

            int value = 1;
            int outdegree = 0;

            const char *line= getEdgeLine();

            // Note: modify this if an edge weight is to be read
            //       modify the 'weight' variable

            sscanf(line, "%lld %lld", &from, &to);
            addEdge(from, to, &weight);

            last_vertex = from;
            ++outdegree;
            for (int64_t i = 1; i < m_total_edge; ++i) {
   
                line= getEdgeLine();
                // Note: modify this if an edge weight is to be read
                //       modify the 'weight' variable
                sscanf(line, "%lld %lld", &from
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值