Skip to content

Commit

Permalink
Remove more usage of graph. #259 #115
Browse files Browse the repository at this point in the history
  • Loading branch information
krlawrence committed Oct 9, 2023
1 parent d8895cf commit 9b5a288
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
28 changes: 10 additions & 18 deletions book/Section-Getting-Started.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -407,24 +407,16 @@ as follows.

[source,groovy]
----
graph = TinkerGraph.open()
g = TinkerGraph.open().traversal()
----

In many cases you will want to pass parameters to the 'open' method that give more
In some cases you will want to pass parameters to the 'open' method providing more
information on how the graph is to be configured. We will explore those options later
on. Before you can start to issue Gremlin queries against the graph you also need to
establish a graph traversal source object by calling the new graph's 'traversal'
method as follows.
on. The variable called 'g' created above is known as a 'graph traversal source' and
will be used throughout the book at the start of each query we write.

[source,groovy]
----
g = graph.traversal()
----

NOTE: Throughout the remainder of this book the following convention will be used.
The variable name 'graph' will be used for any object that represents a graph
instance and the variable name 'g' will be used for any object that represents an
instance of a graph traversal source object.
NOTE: Throughout the remainder of this book the variable name 'g' will be used for
any object that represents an instance of a graph traversal source object.

[[air]]
Introducing the air-routes graph
Expand Down Expand Up @@ -633,8 +625,8 @@ commands shown below, available in the `/sample-data` directory.
https://github.com/krlawrence/graph/tree/main/sample-data

These commands create an in-memory TinkerGraph which will use LONG values for the
vertex, edge and vertex property IDs. As part of loading a 'graph' we need to setup
a graph traversal source object called 'g' which we will then refer to in our
vertex, edge and vertex property IDs. As part of loading a graph we need to setup
a 'graph traversal source' object called 'g' which we will then refer to in our
subsequent queries of the graph. The 'max-iteration' option tells the Gremlin
console the maximum number of lines of output that we ever want to see in return
from a query. The default, if this is not specified, is 100.
Expand All @@ -647,15 +639,15 @@ can still load the `air-routes.graphml` file by following the instructions speci
to that system. Once loaded, the queries below should still work either unchanged or
with minor modifications.

.load-air-routes-graph.groovy
.load-air-routes-graph34.groovy
[source,groovy]
----
conf = new BaseConfiguration()
conf.setProperty("gremlin.tinkergraph.vertexIdManager","LONG")
conf.setProperty("gremlin.tinkergraph.edgeIdManager","LONG")
conf.setProperty("gremlin.tinkergraph.vertexPropertyIdManager","LONG");[]
g = TinkerGraph.open(conf).traversal()
g.io("/mydata/air-routes.graphml"). with(IO.reader,IO.graphml).read().iterate()
g.io("/mydata/air-routes.graphml").with(IO.reader,IO.graphml).read().iterate()
:set max-iteration 1000
----

Expand Down
2 changes: 1 addition & 1 deletion sample-data/load-air-routes-graph-34.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ g = TinkerGraph.open(conf).traversal()
// We need to explicitly tell Gremlin which reader to use as it does not recognize the GraphML
// file extension. It does recognize XML as an extension so an alternative would be to rename
// the file.
g.io("/mydata/air-routes.graphml"). with(IO.reader,IO.graphml).read()
g.io("/mydata/air-routes.graphml"). with(IO.reader,IO.graphml).read().iterate()

:set max-iteration 1000
2 changes: 1 addition & 1 deletion sample-data/load-air-routes-graph.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ conf.setProperty("gremlin.tinkergraph.vertexPropertyIdManager","LONG")
graph = TinkerGraph.open(conf)

// Change the path below to point to wherever you put the graphml file
graph.io(graphml()).readGraph('/mydata/air-routes.graphml')
graph.io(graphml()).readGraph('/mydata/air-routes.graphml').iterate()

g=graph.traversal()
:set max-iteration 1000

0 comments on commit 9b5a288

Please sign in to comment.