我正在寻找Gremlin版本的可自定义的PageRank算法。有几个旧版本,其中一个(从:http://www.infoq.com/articles/graph-nosql-neo4j)被粘贴在下面。我无法将流程融入当前基于GremlinGroovyPipeline的结构中。什么是现代化的相当于这个或类似的东西?Gremlin中可自定义的PageRank算法?
$_g := tg:open()
g:load('data/graph-example-2.xml')
$m := g:map()
$_ := g:key('type', 'song')[g:rand-nat()]
repeat 2500
$_ := ./outE[@label='followed_by'][g:rand-nat()]/inV
if count($_) > 0
g:op-value('+',$m,$_[1]/@name, 1.0)
end
if g:rand-real() > 0.85 or count($_) = 0
$_ := g:key('type', 'song')[g:rand-nat()]
end
end
g:sort($m,'value',true())
另一版本可在幻灯片55的http://www.slideshare.net/slidarko/gremlin-a-graphbased-programming-language-3876581上找到。使用if语句并根据它们更改遍历的能力对于定制非常有用。
千恩万谢