【Linux】graphchi-cpp 程序运行说明

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/coralime/article/details/51602459

源程序:graphchi-cpp

参考文档:graphChi 程序说明.docx

运行环境:Ubuntu 14.04 LTS

步骤:

(1)进入graphchi-cpp文件夹,make编译一下

yfy@yfy-H81M-DS2:~/projects/graphchi/graphchi-cpp$ make

(2)Eample Applications---Pagerank

Source: graphchi-cpp/example_apps/pagerank.cpp

程序运行:

首先make一下pagerank

扫描二维码关注公众号,回复: 3238271 查看本文章
yfy@yfy-H81M-DS2:~/projects/graphchi/graphchi-cpp$ make example_apps/pagerank


编译之后,运行:
yfy@yfy-H81M-DS2:~/projects/graphchi/graphchi-cpp$ bin/example_apps/pagerank file graphdata/test/facebook_combined.txt

【注意】这里的 facebook_combined.txt 是输入的图数据,你可以自行去网上下载其他数据,下载地址在graphChi 程序说明.docx中有详细说明。

会出现一些选项

Please enter value for command-line argument [filetype]
  (Options are: 1.edgelist 2.adjlist 3.binedgelist 4.metis)
根据实际来选择图的类型,这里选择 1 

运行结果:打印输出了前20个拥有最高pagerank值的节点



用Python程序处理输出结果

facebook_combined.txt 文件处理之后,会生成一个 facebook_combined.txt.4B.vout 文件,(GRAPH-NAME.4B.vout),这里我们通过一个test.py脚本来输出结果

test.py 源码:

#!/usr/bin/python
import struct
from array import array as binarray
import sys

inputfile = sys.argv[1]

data = open(inputfile).read()
a = binarray('c')
a.fromstring(data)

s = struct.Struct("f")

l = len(a)

print "%d bytes" %l

n = l / 4

for i in xrange(0,n):
	x = s.unpack_from(a,i*4)[0]
	print ("%d %f" % (i,x))

运行脚本:

yfy@yfy-H81M-DS2:~/projects/graphchi$ python test.py facebook_combined.txt.4B.vout
输出:



(3)其他example_apps下的例子运行过程类似

source:example_apps/connectedcomponents.cpp

source:example_apps/communitydetection.cpp

source:example_apps/als_edgefactors.cpp

source:example_apps/als_vertices_inmem.cpp

Source:https://github.com/GraphChi/graphchi-cpp/blob/master/example_apps/trianglecounting.cpp

Source:https://github.com/GraphChi/graphchi-cpp/blob/master/example_apps/streaming_pagerank.cpp



猜你喜欢

转载自blog.csdn.net/coralime/article/details/51602459