You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/06/25 22:16:52 UTC

[2/2] incubator-tinkerpop git commit: converted static Gephi code samples in the docs into dynamic samples

converted static Gephi code samples in the docs into dynamic samples


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/3c40916f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/3c40916f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/3c40916f

Branch: refs/heads/master
Commit: 3c40916f02c36fefb9d8e93d02146d1c14303c93
Parents: 7cb025a
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu Jun 25 22:16:26 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Thu Jun 25 22:16:26 2015 +0200

----------------------------------------------------------------------
 bin/gephi.mock                         | 24 ++++++++++
 bin/process-docs.sh                    |  2 +
 docs/src/gremlin-applications.asciidoc | 74 +++++++++++------------------
 3 files changed, 53 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3c40916f/bin/gephi.mock
----------------------------------------------------------------------
diff --git a/bin/gephi.mock b/bin/gephi.mock
new file mode 100755
index 0000000..45a3753
--- /dev/null
+++ b/bin/gephi.mock
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+while true
+do
+  echo -e "HTTP/1.1 200 OK\nConnection: close\n\n{}" | nc -l 8080
+done

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3c40916f/bin/process-docs.sh
----------------------------------------------------------------------
diff --git a/bin/process-docs.sh b/bin/process-docs.sh
index 1a62ca2..faa3c4c 100755
--- a/bin/process-docs.sh
+++ b/bin/process-docs.sh
@@ -19,5 +19,7 @@
 #
 
 pushd "$(dirname $0)/.." > /dev/null
+nc -z localhost 8080 || bin/gephi.mock > /dev/null 2>&1 &
 docs/preprocessor/preprocess.sh && mvn process-resources -Dasciidoc && docs/postprocessor/postprocess.sh
+pgrep gephi.mock | xargs -I {} pstree {} -p -a -l | cut -d , -f2 | awk '{print $1}' | xargs kill -PIPE > /dev/null
 popd > /dev/null

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3c40916f/docs/src/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/gremlin-applications.asciidoc b/docs/src/gremlin-applications.asciidoc
index 724aa2a..6a38c4e 100644
--- a/docs/src/gremlin-applications.asciidoc
+++ b/docs/src/gremlin-applications.asciidoc
@@ -858,15 +858,13 @@ image::gephi-start-server.png[width=800]
 
 Start the xref:gremlin-console[Gremlin Console] and activate the Gephi plugin:
 
-[source,groovy]
-gremlin> :plugin use tinkerpop.gephi
-==>tinkerpop.gephi activated
-gremlin> graph = TinkerFactory.createModern()
-==>tinkergraph[vertices:6 edges:6]
-gremlin> :remote connect tinkerpop.gephi
-==>Connection to Gephi - http://localhost:8080/workspace0 with stepDelay:1000, startRGBColor:[0.0, 1.0, 0.5], colorToFade:g, colorFadeRate:0.7
-gremlin> :> graph
-==>tinkergraph[vertices:6 edges:6]
+[gremlin-groovy]
+----
+:plugin use tinkerpop.gephi
+graph = TinkerFactory.createModern()
+:remote connect tinkerpop.gephi
+:> graph
+----
 
 The above Gremlin session activates the Gephi plugin, creates the "modern" `TinkerGraph`, uses the `:remote` command to setup a connection to the Graph Streaming server in Gephi (with default parameters that will be explained below), and then uses `:submit` which sends the vertices and edges of the graph to the Gephi Streaming Server. The resulting graph appears in Gephi as displayed in the left image below.
 
@@ -890,32 +888,20 @@ g.V(2).in().out('knows').
 
 To visualize it insert the appropriately named `store('n')` steps where `n` is an integer, and the vertices will be highlighted in ascending store step order.
 
-[source,groovy]
+[gremlin-groovy,modern]
 ----
-gremlin> g = graph.traversal()
-==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
-gremlin> g.V(2).in('knows').out('knows').has('age',gt(30)).
-               outE('created').has('weight',gt(0.5d)).inV().values('name')
-==>ripple
-gremlin> traversal = g.V(2).store('1')
-gremlin>                    .in('knows').store('2')
-gremlin>                    .out('knows').has('age',gt(30)).store('3')
-gremlin>                    .outE('created').has('weight',gt(0.5d)).inV().store('4')
-==>v[5]
-gremlin> traversal.getSideEffects().get('1')
-==>Optional[{v[2]=1}]
-gremlin> traversal.getSideEffects().get('2')
-==>Optional[{v[1]=1}]
-gremlin> traversal.getSideEffects().get('3')
-==>Optional[{v[4]=1}]
-gremlin> traversal.getSideEffects().get('4')
-==>Optional[{v[5]=1}]
-gremlin> :> traversal
-Visualizing vertices at step: 1... visited: 1
-Visualizing vertices at step: 2... visited: 1
-Visualizing vertices at step: 3... visited: 1
-Visualizing vertices at step: 4... visited: 1
-gremlin>
+g = graph.traversal()
+g.V(2).in('knows').out('knows').has('age',gt(30)).
+       outE('created').has('weight',gt(0.5d)).inV().values('name')
+traversal = g.V(2).store('1').
+       in('knows').store('2').
+       out('knows').has('age',gt(30)).store('3').
+       outE('created').has('weight',gt(0.5d)).inV().store('4')
+traversal.getSideEffects().get('1')
+traversal.getSideEffects().get('2')
+traversal.getSideEffects().get('3')
+traversal.getSideEffects().get('4')
+:> traversal
 ----
 
 When `:> traversal` is called, it iterates through the sideEffects of the traversal accessing the vertices stored at each corresponding step. It then updates the vertices' color with `startRGBColor`, which in this case is a lime-green blue: [0.0,1.0,0.5]. After the first step visualization, it sleeps for the configured `stepDelay` in milliseconds. On the second step, it decays the configured `colorToFade` of all the previously visited vertices in prior steps, by multiplying the current `colorToFade` value for each vertex with the `colorFadeRate`.  To avoid color decay on prior steps, then provide a `colorFadeRate` value of `1.0`.  The screenshots below show how the visualization evolves over the 4 steps:
@@ -924,19 +910,13 @@ image::gephi-traversal.png[width=1200]
 
 Once a traversal visualization has executed, clear the colors in Gephi by selecting the grey square icon under the magnifying glass icon on the lower left tool bar next to the graph canvas.  Run another traversal against the same graph and it will update the appropriate vertices.  To get a sense of how the visualization configuration parameters affect the output, see the example below:
 
-[source,groovy]
-gremlin> :remote config startRGBColor [0.0,0.3,1.0]
-==>Connection to Gephi - http://localhost:8080/workspace0 with stepDelay:1000, startRGBColor:[0.0, 0.3, 1.0], colorToFade:g, colorFadeRate:0.7
-gremlin> :remote config colorToFade b
-==>Connection to Gephi - http://localhost:8080/workspace0 with stepDelay:1000, startRGBColor:[0.0, 0.3, 1.0], colorToFade:b, colorFadeRate:0.7
-gremlin> :remote config colorFadeRate 0.5
-==>Connection to Gephi - http://localhost:8080/workspace0 with stepDelay:1000, startRGBColor:[0.0, 0.3, 1.0], colorToFade:b, colorFadeRate:0.5
-gremlin> :> traversal
-Visualizing vertices at step: 1... visited: 1
-Visualizing vertices at step: 2... visited: 1
-Visualizing vertices at step: 3... visited: 1
-Visualizing vertices at step: 4... visited: 1
-gremlin>
+[gremlin-groovy,modern]
+----
+:remote config startRGBColor [0.0,0.3,1.0]
+:remote config colorToFade b
+:remote config colorFadeRate 0.5
+:> traversal
+----
 
 image::gephi-traversal-config.png[width=400]