You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/06/13 18:10:10 UTC
svn commit: r1748292 - /tinkerpop/site/docs/3.2.1-SNAPSHOT/recipes/index.html
Author: spmallette
Date: Mon Jun 13 18:10:10 2016
New Revision: 1748292
URL: http://svn.apache.org/viewvc?rev=1748292&view=rev
Log:
Improved the centrality recipe in TinkerPop docs
Modified:
tinkerpop/site/docs/3.2.1-SNAPSHOT/recipes/index.html
Modified: tinkerpop/site/docs/3.2.1-SNAPSHOT/recipes/index.html
URL: http://svn.apache.org/viewvc/tinkerpop/site/docs/3.2.1-SNAPSHOT/recipes/index.html?rev=1748292&r1=1748291&r2=1748292&view=diff
==============================================================================
--- tinkerpop/site/docs/3.2.1-SNAPSHOT/recipes/index.html (original)
+++ tinkerpop/site/docs/3.2.1-SNAPSHOT/recipes/index.html Mon Jun 13 18:10:10 2016
@@ -1505,20 +1505,58 @@ the <code>sack()</code> which was initia
<p>A calculation of <a href="https://en.wikipedia.org/wiki/Centrality#Eigenvector_centrality">eigenvector centrality</a> uses the
relative importance of adjacent vertices to help determine their centrality. In other words, unlike
<a href="#degree-centrality">degree centrality</a> the vertex with the greatest number of incident edges does not necessarily
-give it the highest rank.</p>
+give it the highest rank. Consider the following example using the Grateful Dead graph:</p>
</div>
<div class="listingblock">
<div class="content">
-<pre class="CodeRay"><code class="groovy language-groovy">gremlin> g.V().repeat(groupCount(<span class="string"><span class="delimiter">'</span><span class="content">m</span><span class="delimiter">'</span></span>).out()).times(<span class="integer">30</span>).cap(<span class="string"><span class="delimiter">'</span><span class="content">m</span><span class="delimiter">'</span></span>)
-==>[v[<span class="integer">1</span>]:<span class="integer">1</span>, v[<span class="integer">2</span>]:<span class="integer">2</span>, v[<span class="integer">3</span>]:<span class="integer">5</span>, v[<span class="integer">4</span>]:<span class="integer">2</span>, v[<span class="integer">5</span>]:<span class="integer">3</span>, v[<span class="integer">6</span>]:<span class="integer">1</span>]</code></pre>
+<pre class="CodeRay"><code class="groovy language-groovy">gremlin> graph.io(graphml()).readGraph(<span class="string"><span class="delimiter">'</span><span class="content">data/grateful-dead.xml</span><span class="delimiter">'</span></span>)
+==><span class="predefined-constant">null</span>
+gremlin> g.V().repeat(groupCount(<span class="string"><span class="delimiter">'</span><span class="content">m</span><span class="delimiter">'</span></span>).by(<span class="string"><span class="delimiter">'</span><span class="content">name</span><span class="delimiter">'</span></span>).out()).times(<span class="integer">5</span>).cap(<span class="string"><span class="delimiter">'</span><span class="content">m</span><span class="delimiter">'</span></span>). <span class="comment">//</span><b>(1)</b>
+ order(local).by(values, decr).limit(local, <span class="integer">10</span>).next() <span class="comment">//</span><b>(2)</b>
+==>PLAYING IN THE BAND=<span class="integer">8758598</span>
+==>ME AND MY UNCLE=<span class="integer">8214246</span>
+==>JACK STRAW=<span class="integer">8173882</span>
+==>EL PASO=<span class="integer">7666994</span>
+==>TRUCKING=<span class="integer">7643494</span>
+==>PROMISED LAND=<span class="integer">7339027</span>
+==>CHINA CAT SUNFLOWER=<span class="integer">7322213</span>
+==>CUMBERLAND BLUES=<span class="integer">6730838</span>
+==>RAMBLE ON ROSE=<span class="integer">6676667</span>
+==>LOOKS LIKE RAIN=<span class="integer">6674121</span>
+gremlin> g.V().repeat(groupCount(<span class="string"><span class="delimiter">'</span><span class="content">m</span><span class="delimiter">'</span></span>).by(<span class="string"><span class="delimiter">'</span><span class="content">name</span><span class="delimiter">'</span></span>).out().timeLimit(<span class="integer">100</span>)).times(<span class="integer">5</span>).cap(<span class="string"><span class="delimiter">'</span><span class="content">m</span><span class="delimiter">'</span></span>). <span class="comment">//</span><b>(3)</b>
+ order(local).by(values, decr).limit(local, <span class="integer">10</span>).next()
+==>PLAYING IN THE BAND=<span class="integer">329888</span>
+==>ME AND MY UNCLE=<span class="integer">308864</span>
+==>JACK STRAW=<span class="integer">308566</span>
+==>EL PASO=<span class="integer">288343</span>
+==>TRUCKING=<span class="integer">286078</span>
+==>CHINA CAT SUNFLOWER=<span class="integer">280274</span>
+==>PROMISED LAND=<span class="integer">273845</span>
+==>RAMBLE ON ROSE=<span class="integer">258341</span>
+==>CUMBERLAND BLUES=<span class="integer">255247</span>
+==>SCARLET BEGONIAS=<span class="integer">254487</span></code></pre>
</div>
</div>
-<div class="paragraph">
+<div class="colist arabic">
+<ol>
+<li>
<p>The traversal iterates through each vertex in the graph and for each one repeatedly group counts each vertex that
passes through using the vertex as the key. The <code>Map</code> of this group count is stored in a variable named "m". The
-<code>out()</code> traversal is repeated thirty times or until the paths are exhausted. Thirty iterations should provide enough
-time to converge on a solution. Calling <code>cap('m')</code> at the end simply extracts the <code>Map</code> side-effect stored in "m"
-and returns it from the traversal as the result.</p>
+<code>out()</code> traversal is repeated thirty times or until the paths are exhausted. Five iterations should provide enough
+time to converge on a solution. Calling <code>cap('m')</code> at the end simply extracts the <code>Map</code> side-effect stored in "m".</p>
+</li>
+<li>
+<p>The entries in the <code>Map</code> are then iterated and sorted with the top ten most central vertices presented as output.</p>
+</li>
+<li>
+<p>The previous examples can be expanded on a little bit by including a
+<a href="http://tinkerpop.apache.org/docs/current/reference/#timelimit-step">time limit</a>. The <code>timeLimit()</code> prevents the
+traversal from taking longer than one hundred milliseconds to execute (the previous example takes considerably longer
+than that). While the answer provided with the <code>timeLimit()</code> is not the absolute ranking, it does provide a relative
+ranking that closely matches the absolute one. The use of <code>timeLimit()</code> in certain algorithms (e.g. recommendations)
+can shorten the time required to get a reasonable and usable result.</p>
+</li>
+</ol>
</div>
</div>
</div>
@@ -1824,7 +1862,7 @@ submissions!</p>
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2016-06-13 11:56:53 -04:00
+Last updated 2016-06-13 14:08:20 -04:00
</div>
</div>
</body>