当前位置:网站首页>Rapidly develop GraphScope graph analysis applications
Rapidly develop GraphScope graph analysis applications
2022-07-30 07:36:00 【graphscope】
我们开发了一个 C++ 模板库,Users only need to replace a few functions with custom logic,You can customize the graph analysis algorithm and run it GraphScope 上.
Graphs are an important data source for big data,Various analytical techniques surrounding graphs also have wide-ranging applications.The core of graph computing lies in algorithms,如 PageRank、K-Core Algorithms such as these have shown powerful capabilities in node importance analysis scenarios.GraphScope The graph analysis engine of GRAPE 系统的开源版本,A variety of graph analysis algorithms are built in,can be found in the path、Community discovery and other fields provide one-stop graph analysis solutions;然而,Users often need to customize some algorithms according to their own needs,因此,In order to facilitate users to develop custom graph analysis algorithms,我们提供了一个 C++ 模版库,The next part of this article will introduce how to use the template library.
Step1. 安装 GraphScope
首先,We need to install it in the local environment with the following command GraphScope:
pip3 install graphscope
Step2. Develop algorithms using template libraries
使用浏览器打开template library GitHub 地址,Click to the right of the library Use this template
button to create a code repository of your own,And clone the repository locally with the following command:
# Make sure to replace the <username> and <repo-name> to the right values.
git clone https://github.com/<username>/<repo-name>.git
cd <repo-name>
接下来,我们通过修改 src
目录下的文件,Implement custom algorithm logic,其中:
my_app.h
: This file is used to implement the main logic of the algorithm,即PEval
和IncEval
函数;my_app_context.h
: 该文件用于存储、Define the results of the algorithm when it runs and the data structures used.
Defines the data structures that the algorithm needs to run
To simplify the algorithm logic,Highlight the development process of the algorithm,在本例中,Our algorithm will take care of thatThe sum of the degrees of each node's neighbors in the graph.在这一步中,我们需要在 my_app_context.h
文件中:1) Defines the data structure of the algorithm runtime;2) 在 Init
function to initialize these data structures.
The algorithm runtime data structure is as follows:
变量名 | 类型 | 作用 |
---|---|---|
result | vertex_array_t<size_t> | Store the calculation result of each node |
degree | vertex_array_t<size_t> | 辅助数据结构,Stores the degree of each node |
最终,my_app_context.h
实现如下:
Implement algorithm logic
After the data structure is defined,我们可在 my_app.h
The corresponding algorithm logic is implemented in,即 PEval 和 IncEval 函数.关于 PEval 和 IncEval 函数的定义,可参考 PIE Introduction to the programming model.在这个例子中,
- PEval 函数: Get the degree of each internal node,and send messages along the outgoing edge;
- IncEval 函数: 1) 负责接收、Process messages from the previous round;2) Count the sum of the degrees of each node's neighbor nodes.
最终,完整的 my_app.h
实现如下:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8WsI3SVy-1658738305019)(https://files.mdnice.com/user/24781/653b7ec0-fca7-46d0-b9f9-3614d52b8f71.png)]
Step3. 构建并测试
Build and test your algorithm locally
使用如下命令,Compile the build algorithm:
make build & cd build
cmake .. && make # compilation algorithm
make package # Package the algorithm as available GraphScope resources running on it (.gar文件)
在 GraphScope Run the algorithm on the cluster
算法开发完成后,We can then assign the corresponding algorithm resources (gar文件) 运行在 GraphScope 集群上,具体步骤如下:
import graphscope
graphscope.set_option(show_log=True)
from graphscope.framework.app import load_app
from graphscope.dataset import load_p2p_network
sess = graphscope.session(cluster_type="hosts")
simple_graph = load_p2p_network(sess)._project_to_simple()
my_app = load_app('<path_to_your_gar_resource>')
result = my_app(simple_graph)
print(result.to_numpy("r"))
结语
本文详细介绍了如何基于 C++ The template library can quickly develop a template library GraphScope Graph analytics algorithms running on the cluster,In the future, we will also share more algorithm cases developed based on this template library in real scenarios,敬请期待!点击链接The source code of the template library can be obtained.同时也欢迎关注 GraphScope 公众号及GitHub,及时了解图计算相关的知识及 GraphScope 的研发进展.
边栏推荐
- The most complete difference between sizeof and strlen, as well as pointer and array operation analysis
- 元宇宙与图扑国风的碰撞,科技与文化的虚实融合
- How to create a shortcut without the "shortcut" suffix?
- 单向链表的操作(带头结点)
- arthas常用命令
- 基于精灵(Sprite)管道烟雾流动效果
- Biotin-Dadps-azide|CAS:1260247-50-4|生物素-DADPS-叠氮
- D-Desthiobiotin Amine_D-脱硫生物素-胺相关的产品性质
- 力扣题解7.27
- SQL并列排序问题
猜你喜欢
Event Delivery and Responder Chains
数码管动态显示及模块化编程
Shortcut keys commonly used in the use of Word
DADPS-生物素-炔基_CAS:2241685-22-1试剂反应原理
Biotinyl Cystamine_CAS:128915-82-2_生物素半胱胺
04-加壳和脱壳
图扑数字孪生煤矿开采系统,打造采煤“硬实力”
The Force Plan Microservices | Centralized Configuration Center Config Asymmetric Encryption and Security Management
单向链表的操作(带头结点)
IO进程线程->文件IO->day2
随机推荐
掌握JESD204B(二)–AD6676的调试
led闪烁
GNNLab:基于空间共享思想设计的新型 GNN 系统
mysql数据库怎么设置手动提交
Knowledge of the day: handwritten deep copy and shallow copy (solves the problem of circular references)
独立按键控制led
VSCode hides the left activity bar
How to import matlab data into modelsim simulation
网络协议04 - 物理层和数据链路层
C 语言之学生管理系统-多文件编程
测试第一题
com.alibaba.datax.common.exception.DataXException: Code:[ESWriter-03]
不依赖框架的文件下载
02-Use of Cycript
一种新的DNA生物素系统Biotin LC hydrazide|CAS:109276-34-8|(+)-生物素酰胺基己酸肼
从 Vertex 到 Subgraph 再到 PIE: 并行图计算编程模型概览
瀑布流(自定义布局实现)
Alamofire source code analysis - POST request
从安装到编译: 10分钟教你在本地使用和开发GraphScope
GAIA-IR:GraphScope 上的并行化图查询引擎