title: customizable PageRank algorithm in Gremlin?
body: <p>I'm looking for a Gremlin version of a customizable PageRank algorithm.  There are a few old versions out there, one (from: <a href="http://www.infoq.com/articles/graph-nosql-neo4j" rel="nofollow">http://www.infoq.com/articles/graph-nosql-neo4j</a>) is pasted below.  I'm having trouble fitting the flow into the current GremlinGroovyPipeline-based structure.  What is the modernized equivalent of this or something like it?</p>
  
  <pre><code>$_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($_) &gt; 0
      g:op-value('+',$m,$_[1]/@name, 1.0)
    end
  
    if g:rand-real() &gt; 0.85 or count($_) = 0
      $_ := g:key('type', 'song')[g:rand-nat()]
    end
  end
  
  g:sort($m,'value',true())
  </code></pre>
  
  <p>Another version is available on slide 55 of <a href="http://www.slideshare.net/slidarko/gremlin-a-graphbased-programming-language-3876581" rel="nofollow">http://www.slideshare.net/slidarko/gremlin-a-graphbased-programming-language-3876581</a>.  The ability to use the if statements and change the traversal based on them is valuable for customization.  </p>
  
  <p>many thanks</p>