http://blog.csdn.net/pipisorry/article/details/51350908

export HADOOP_HOME=/usr/local/hadoop-2.6.4
export GRAPHLITE_HOME=/opt/GraphLite/GraphLite-0.20

pika:/opt/GraphLite/GraphLite-0.20$ . bin/setenv
pika:/opt/GraphLite/GraphLite-0.20$cd engine
pika:/opt/GraphLite/GraphLite-0.20/engine$make       #apt-get install -y make      #没有安装make的话要安装
pika:/opt/GraphLite/GraphLite-0.20/engine$cd ..
pika:/opt/GraphLite/GraphLite-0.20$ls bin/
clean-output  graphlite  hash-partitioner.pl  setenv  start-graphlite  start-worker

Compile and Run Vertex Program

1. build example

pika:/opt/GraphLite/GraphLite-0.20$cd example

如果没有安装g++的要安装apt-get install -y g++

pika:/opt/GraphLite/GraphLite-0.20/example$make
g++ -std=c++0x -g -O2 -I/usr/local/hadoop-2.6.4/include -I/opt/GraphLite/GraphLite-0.20/include PageRankVertex.cc -fPIC -shared -o PageRankVertex.so
check if example/PageRankVertex.so is successfully generated:

pika:/opt/GraphLite/GraphLite-0.20/example$ls
Makefile  PageRankVertex.cc  PageRankVertex.so

2. run example

如果没有开启ssh的要开启/etc/init.d/ssh start,一般上面步骤对都开启了

pika:/opt/GraphLite/GraphLite-0.20/example$cd ..

pika:/opt/GraphLite/GraphLite-0.20$start-graphlite example/PageRankVertex.so Input/facebookcombined_4w Output/out

Note: 如果这一步出错了,直接ctrl+c并没有杀掉所有graphlite进程,系统cpu占用还是100%,所以要打开系统监视器来end process: 进程名为graphlite。

查看输出结果:

pika:/opt/GraphLite/GraphLite-0.20$cat Output/out_*

...

4031: 1.050963
4035: 0.152987

当然也可以测试自己写的代码和输入文件

编写自己的同步图计算程序并测试代码结果

计算KCore:一个图G的 KCore 是G的子图,这个子图的每个顶点的度>=K;输入:无向图 (有成对的有向边);输出:  KCore 子图中的所有顶点

#将自己写的代码KcoreVertex.cc和输入文件的目录(/media/pika/files/mine/c_workspace/BDMS/BDMS代码和输入文件下载)cp到graphlite example目录下

pika:/opt/GraphLite/GraphLite-0.20$cd example/

pika:/opt/GraphLite/GraphLite-0.20/example$mv PageRankVertex.cc ori.cc                   #重命名之前的文件

pika:/opt/GraphLite/GraphLite-0.20/example$rm PageRankVertex.so -f                          #删除之前产生的中间文件

pika:/opt/GraphLite/GraphLite-0.20/example$cp /media/pika/files/mine/c_workspace/BDMS/BDMS/*.cc /opt/GraphLite/GraphLite-0.20/example
pika:/opt/GraphLite/GraphLite-0.20/example$cp /media/pika/files/mine/c_workspace/BDMS/BDMS/part2-input/* /opt/GraphLite/GraphLite-0.20/Input
pika:/opt/GraphLite/GraphLite-0.20/example$. ../bin/setenv
pika:/opt/GraphLite/GraphLite-0.20/example$make

pika:/opt/GraphLite/GraphLite-0.20$cd ..

#PageRankVertex实际已改成自己写的KcoreVertex,文件名修改的话也要修改Makefile文件再make

pika:/opt/GraphLite/GraphLite-0.20$start-graphlite example/PageRankVertex.so Input/KCore-graph0_4w Output/out 6

pika:/opt/GraphLite/GraphLite-0.20$cat Output/out_*

0
4
1
5
2
6
3

Graphlite程序的调试

lz并没有深入graphlite,调试仅仅是输出中间值。

在graphlite c++代码中(一般只是修改了节点的compute函数代码)cout输出结果,结果不会在屏幕上输出,但是会在${GRAPHLITE_HOME}目录中的workout目录下有文件输出。

通过设置最大超步数,一步一步调试吧。

注意事项

graphlite的c++代码(如compute函数中读取的数据)中的相对路径是相对${GRAPHLITE_HOME}来说的,也就是相对执行目录而言,而不是相对.cc代码或者.so文件。

运行出错及解决

Sender: connect: Connection refused错误

Sender: connect: Connection refused

Sender: connect: Connection refused

...

出错的可能原因:

1 可能是inputformatter中顶点类型的sizeof没改,或者说是某个类型定义为double,但是传递的是int

2 执行路径不对:example/PageRankVertex.so,这个路径就说明要在example的上级目录下执行这条命令
3 运行之前还有其它graphlite程序在运行,可能是之前运行graphlite时ctrl+c结束了,但是实际上进行还在后台执行,导致冲突,打开system-monitor结束graphlite进程(一般有多少个worker就有几个进程,都要结束)

皮皮blog

Netbeans IDE中调试基于graphlite实现的c++代码

...

皮皮blog

Docker中运行graphlite

Requirements

1. JDK 1.7.x + Hadoop 2.6.x

docker中Hadoop的安装参考[Hadoop:Hadoop单机伪分布式的安装和配置]

2. protocol buffers

root@dc34d732b74d:/# apt-get update

root@dc34d732b74d:/# sudo apt-get install protobuf-c-compiler libprotobuf-c0 libprotobuf-c0-dev

下载和安装graphlite

root@dc34d732b74d:/# apt-get install -y git              #没有安装git的话要安装,lz使用的是docker中配置的环境,很多都没有

root@dc34d732b74d:/# cd /opt

root@dc34d732b74d:/opt# git clone https://github.com/schencoding/GraphLite.git

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# vim bin/setenv 
export JAVA_HOME=/opt/jdk1.8.0_91
export HADOOP_HOME=/usr/local/hadoop-2.6.4
export GRAPHLITE_HOME=/opt/GraphLite/GraphLite-0.20
root@dc34d732b74d:/opt# . bin/setenv

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# cd engine

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/engine# apt-get install -y make      #没有安装make的话要安装
root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/engine# make

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/engine# cd ..

check if bin/graphlite is successfully generated:

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# ls bin/          
clean-output  graphlite  hash-partitioner.pl  setenv  start-graphlite  start-worker

Compile and Run Vertex Program

1. build example

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# cd example

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# apt-get install -y g++    #没有安装g++的要安装

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/example# make
g++ -std=c++0x -g -O2 -I/usr/local/hadoop-2.6.4/include -I/opt/GraphLite/GraphLite-0.20/include PageRankVertex.cc -fPIC -shared -o PageRankVertex.so
check if example/PageRankVertex.so is successfully generated:

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/example# ls
Makefile  PageRankVertex.cc  PageRankVertex.so
2. run example

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/example# cd ..

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20/# /etc/init.d/ssh start           #没有开启ssh的要开启

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# start-graphlite example/PageRankVertex.so Input/facebookcombined_4w Output/out

查看输出结果:

root@dc34d732b74d:/opt/GraphLite/GraphLite-0.20# cat Output/out_*

保存docker 容器为images

pika:~$docker ps

pika:~$docker commit 2379 graphlite1

当然也可以测试自己写的代码和输入文件

编写自己的同步图计算程序并测试代码结果

#将自己写的代码KcoreVertex.cc和输入文件的目录(代码和输入文件下载)挂载到docker image的/mnt目录下

Note: KcoreVertex.cc内容:KCore:一个图G的 KCore 是G的子图,这个子图的每个顶点的度>=K;输入:无向图 (有成对的有向边);输出:  KCore 子图中的所有顶点

pika:~$docker run -v /media/pika/files/mine/c_workspace/BDMS/BDMS:/mnt -it graphlite1 bash

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# mv PageRankVertex.cc ori.cc   #重命名之前的文件

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# rm PageRankVertex.so #删除之前产生的中间文件

root@23791b4028eb:/# cp /mnt/*.cc /opt/GraphLite/GraphLite-0.20/example

root@23791b4028eb:/# cp /mnt/part2-input/* /opt/GraphLite/GraphLite-0.20/Input

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20#  . bin/setenv

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# cd example/

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# make

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20/example# cd ..

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# /etc/init.d/ssh start

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# start-graphlite example/PageRankVertex.so Input/KCore-graph0_4w Output/out 6     #PageRankVertex实际已改成自己写的KcoreVertex,文件名修改的话也要修改Makefile文件再make

root@23791b4028eb:/opt/GraphLite/GraphLite-0.20# cat Output/out_*
0
4
1
5
2
6
3

pika:~$docker ps

pika:~$docker commit <container id> graphlite

from: http://blog.csdn.net/pipisorry/article/details/51350908

ref: GraphLite的github主页

Prege(图计算框架)l: A System for Large-Scale Graph Processing(译)

分布式图并行计算框架:PowerGraph

同步图计算:GraphLite的安装和使用的更多相关文章

  1. 同步图计算实现最短路径Dijkstra算法

    同上篇讲述pageRank一样,考虑一个顶点V. 根据顶点算法通常步骤1) 接收上个超步发出的入邻居的消息2) 计算当前顶点的值3) 向出邻居发消息 1.接收入邻居的消息 2.求入邻居的最小值,加上顶 ...

  2. 同步图计算实现pageRank算法

    pageRank算法是Google对网页重要性的打分算法. 一个用户浏览一个网页时,有85%的可能性点击网页中的超链接,有15%的可能性转向任意的网页.pageRank算法就是模拟这种行为. Rv:定 ...

  3. 开源图计算框架GraphLab介绍

    GraphLab介绍 GraphLab 是由CMU(卡内基梅隆大学)的Select 实验室在2010 年提出的一个基于图像处理模型的开源图计算框架.框架使用C++语言开发实现. 该框架是面向机器学习( ...

  4. Spark入门实战系列--9.Spark图计算GraphX介绍及实例

    [注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .GraphX介绍 1.1 GraphX应用背景 Spark GraphX是一个分布式图处理 ...

  5. 明风:分布式图计算的平台Spark GraphX 在淘宝的实践

    快刀初试:Spark GraphX在淘宝的实践 作者:明风 (本文由团队中梧苇和我一起撰写,并由团队中的林岳,岩岫,世仪等多人Review,发表于程序员的8月刊,由于篇幅原因,略作删减,本文为完整版) ...

  6. 关于图计算和graphx的一些思考[转]

    原文链接:http://www.tuicool.com/articles/3MjURj “全世界的网络连接起来,英特纳雄耐尔就一定要实现.”受益于这个时代,互联网从小众的角落走到了历史的中心舞台.如果 ...

  7. Spark(十七)图计算GraphX

    一.图概念术语 1.1 基本概念 图是由顶点集合(vertex)及顶点间的关系集合(边edge)组成的一种数据结构. 这里的图并非指代数中的图.图可以对事物以及事物之间的关系建模,图可以用来表示自然发 ...

  8. MaxCompute 图计算开发指南

    快速入门step by step MaxCompute Studio 创建完成 MaxCompute Java Module后,即可以开始开发Graph了. 代码示例 在examples目录下有gra ...

  9. GraphX 在图数据库 Nebula Graph 的图计算实践

    不同来源的异构数据间存在着千丝万缕的关联,这种数据之间隐藏的关联关系和网络结构特性对于数据分析至关重要,图计算就是以图作为数据模型来表达问题并予以解决的过程. 一.背景 随着网络信息技术的飞速发展,数 ...

随机推荐

  1. ●BZOJ 1185 [HNOI2007]最小矩形覆盖

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1185 题解: 计算几何,凸包,旋转卡壳 结论:矩形的某一条边在凸包的一条边所在的直线上. ( ...

  2. HDU 4501

    超市里有n件他想要的商品.小明顺便对这n件商品打了分,表示商品的实际价值.小明发现身上带了v1的人民币,会员卡里面有v2的积分,而且他能免费拿k件.他想知道他最多能买多大价值的商品. 由于小明想要的商 ...

  3. 【bzoj4571 scoi2016】美味

    题目描述 一家餐厅有 n 道菜,编号 1...n ,大家对第 i 道菜的评价值为 ai(1<=i<=n).有 m 位顾客,第 i 位顾客的期望值为 bi,而他的偏好值为 xi .因此,第 ...

  4. [4.14校内训练赛by hzwer]

    来自FallDream的博客,未经允许,请勿转载,谢谢. hzwer又出丧题虐人 4道noi....        很奇怪 每次黄学长出题总有一题我做过了. 嗯题目你们自己看看呗 好难解释 ----- ...

  5. 使用JAXB解析xml文件(一)

      1.java中解析xml的几种方式 1.1 JDK原生dom形式 原理:一次性把xml读入内存,在内存中构建成树形结构.优点:对节点操作方便,缺点:需要大量的内存空间,浪费资源 1.2 SAX形式 ...

  6. python 类的特殊成员方法

    __doc__ # 输出类的描述信息 __module__ # 表示当前操作的对象在那个模块 __class__ # 表示当前操作的对象的类是什么 __init__ # 构造方法,通过类创建对象是,自 ...

  7. Windows Server 2008 R2服务器系统安全设置参考指南

    Server 2008 R2服务器系统安全设置参考指南  重点比较重要的几部 1.更改默认administrator用户名,复杂密码 2.开启防火墙 3.安装杀毒软件 1)新做系统一定要先打上补丁(升 ...

  8. Redis集群搭建方案(Linux)

    Redis简介 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串). list(链表).set(集合)和zset(有序 ...

  9. Hibernate QBC 条件查询(Criteria Queries) and Demos

    目录 创建一个Criteria 实例 限制结果集内容 结果集排序 关联 动态关联抓取 查询示例 投影Projections聚合aggregation和分组grouping 离线detached查询和子 ...

  10. Python 字符串字典内置函数&方法

    Python字典包含了以下内置函数: 序号 函数及描述 1 cmp(dict1, dict2)比较两个字典元素. 2 len(dict)计算字典元素个数,即键的总数. 3 str(dict)输出字典可 ...