# PRACTICAL GREMLIN: An Apache TinkerPop Tutorial > A practical, example-driven tutorial for learning the Apache TinkerPop graph computing framework and the Gremlin graph traversal language, using the air-routes sample graph. ## INTRODUCTION - [INTRODUCTION](https://krlawrence.github.io/graph/md/introduction/index.md): Introduces Apache TinkerPop and why graph databases matter, and explains how this book, its sample code, and its data sets are organized. ## GETTING STARTED - [GETTING STARTED](https://krlawrence.github.io/graph/md/getting-started/index.md): Sets up the Gremlin Console and TinkerGraph and loads the air-routes sample graph used for the examples throughout the book. ## WRITING GREMLIN QUERIES - [WRITING GREMLIN QUERIES](https://krlawrence.github.io/graph/md/writing-gremlin-queries/index.md): Opens the chapter on read-only Gremlin traversals against the air-routes graph, previewing how the language builds from basic to advanced queries. - [Introducing Gremlin](https://krlawrence.github.io/graph/md/writing-gremlin-queries/introducing-gremlin.md): Introduces Gremlin as TinkerPop's graph traversal language, contrasting 'out' hops and 'repeat' with SQL joins and explaining why graphs suit connected data. - [Some fairly basic Gremlin queries](https://krlawrence.github.io/graph/md/writing-gremlin-queries/some-fairly-basic-gremlin-queries.md): Starts traversals with 'g.V()' and 'g.E()', filtering by 'has' and 'hasLabel', reading 'values', and counting with 'count', 'group' and 'groupCount'. - [Starting to walk the graph](https://krlawrence.github.io/graph/md/writing-gremlin-queries/starting-to-walk-the-graph.md): Walks the graph with 'out', 'in', 'outE' and 'inV', capturing journeys via 'path' with 'by', 'from' and 'to', plus 'as', 'select' and 'project'. - [Limiting the amount of data returned](https://krlawrence.github.io/graph/md/writing-gremlin-queries/limiting-the-amount-of-data-returned.md): Restricts result size using 'limit', 'range', 'skip', 'tail' and 'timeLimit', with patterns for retrieving ranges and penultimate stream elements. - [Removing duplicates - introducing 'dedup'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/removing-duplicates---introducing-dedup.md): Removes duplicate results with 'dedup', including a 'by' modulator form and a labeled-step form that deduplicates against 'as' references. - [Using 'valueMap' to explore the properties of a vertex or edge](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-valuemap-to-explore-the-properties-of-a-vertex-or-edge.md): Explores vertex and edge properties with 'valueMap', selecting keys, adding id and label via 'true' or 'WithOptions.tokens', and unwrapping lists. - [An alternative to 'valueMap' - introducing 'elementMap'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/an-alternative-to-valuemap---introducing-elementmap.md): Presents 'elementMap' as a simpler alternative to 'valueMap' that always includes id and label and returns incoming and outgoing vertex details for edges. - [Assigning query results to a variable with a terminal step](https://krlawrence.github.io/graph/md/writing-gremlin-queries/assigning-query-results-to-a-variable-with-a-terminal-step.md): Terminates traversals to store results using 'next', 'toList', 'toSet', 'toBulkSet' and 'fill', and discards output with 'iterate'. - [Deep dive on traversal terminology](https://krlawrence.github.io/graph/md/writing-gremlin-queries/deep-dive-on-traversal-terminology.md): Defines core terminology: the 'GraphTraversalSource' g, start and terminal steps, and anonymous traversals spawned from the double-underscore class. - [Working with IDs](https://krlawrence.github.io/graph/md/writing-gremlin-queries/working-with-ids.md): Explains that every element has an immutable, possibly regenerated id, and looks things up with 'id', 'hasId' and IDs passed into the 'V' step. - [Working with labels](https://krlawrence.github.io/graph/md/writing-gremlin-queries/working-with-labels.md): Uses immutable labels to group elements, filtering with 'hasLabel', 'label', the label keyword, and the three-parameter 'has' form. - [Using the 'local' step to make sure we get the result we intended](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-the-local-step-to-make-sure-we-get-the-result-we-intended.md): Shows how wrapping steps in 'local' fixes per-element calculations like 'mean' route counts and builds lists of lists per airport. - [Basic statistical and numerical operations](https://krlawrence.github.io/graph/md/writing-gremlin-queries/basic-statistical-and-numerical-operations.md): Covers the statistical steps 'count', 'sum', 'max', 'min' and 'mean', noting that 'min' and 'max' also work on comparable values like strings. - [Working with text](https://krlawrence.github.io/graph/md/writing-gremlin-queries/working-with-text.md): Manipulates strings with steps such as 'asString', 'toLower', 'length', 'substring', 'split', 'replace', 'concat' and 'format', including 'local' scope. - [Working with collections](https://krlawrence.github.io/graph/md/writing-gremlin-queries/working-with-collections.md): Manipulates lists, sets and maps with steps like 'any', 'all', 'none', 'combine', 'intersect', 'reverse' and 'merge', plus 'select' for map keys and values. - [Working with dates](https://krlawrence.github.io/graph/md/writing-gremlin-queries/working-with-dates.md): Handles dates with 'asDate', the 'datetime' function, and the 'dateAdd' and 'dateDiff' steps using the DT time-unit enum. - [Testing values and ranges of values with P](https://krlawrence.github.io/graph/md/writing-gremlin-queries/testing-values-and-ranges-of-values-with-p.md): Tests values with P predicates like 'gt', 'inside', 'between', 'within' and 'without', contrasts 'neq' with 'not', and samples data using 'coin' and 'sample'. - [Checking data types with 'typeOf'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/checking-data-types-with-typeof.md): Identifies object types with the 'typeOf' predicate and the GType enum, filtering paths to keep only vertices or spotting wrongly typed property data. - [Text search predicates](https://krlawrence.github.io/graph/md/writing-gremlin-queries/text-search-predicates.md): Searches string properties with case-sensitive text predicates 'startingWith', 'endingWith', 'containing', 'regex' and their negated counterparts. - [Sorting things – introducing 'order'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/sorting-things--introducing-order.md): Sorts results with 'order', using 'by' with 'asc', 'desc' and 'shuffle', ordering maps by 'keys' or 'values' with 'local', and noting unproductive-by filtering. - [Boolean operations](https://krlawrence.github.io/graph/md/writing-gremlin-queries/boolean-operations.md): Forms logical queries with the 'and', 'or' and 'not' steps, showing infix and dot-combined forms and when 'within', 'without' or chained 'has' are cleaner. - [Using 'where' to filter things out of a result](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-where-to-filter-things-out-of-a-result.md): Filters traversals with 'where', combining it with 'is', 'by' modulators, two-parameter label comparisons, and 'not' to invert conditions. - [Using 'choose' to write if...then...else type queries](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-choose-to-write-ifthenelse-type-queries.md): Writes if-then-else logic with 'choose', returning derived or 'constant' values based on a predicate, with implied else behavior. - [Using 'option' to write case/switch type queries](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-option-to-write-caseswitch-type-queries.md): Combines 'choose' with 'option' for case/switch queries, using 'none' as the default and predicates like 'gt' to categorize airports. - [Using 'match' to do pattern matching](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-match-to-do-pattern-matching.md): Expresses declarative patterns with 'match' to find routes lacking return flights, and shows simpler equivalents written with 'where'. - [Using 'union' to combine query results](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-union-to-combine-query-results.md): Combines multiple traversal branches with 'union', using it as a start step and mixing in 'identity', 'constant', 'local' and 'filter'. - [Using 'sideEffect' to do things on the side](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-sideeffect-to-do-things-on-the-side.md): Performs extra work without altering the stream using 'sideEffect', aggregating counts into labels and running closures such as a println. - [Using 'aggregate' to create a temporary collection](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-aggregate-to-create-a-temporary-collection.md): Uses 'aggregate' to stash visited vertices in a named collection, then 'where' with 'without' to exclude non-stop destinations when counting one-stop routes. - [Using 'inject' to insert values into a query](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-inject-to-insert-values-into-a-query.md): Inserts extra values into a traversal with 'inject', including the trick of following 'g' with 'inject' so a 'choose' step can be used. - [Using 'coalesce' to see which traversal returns a result](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-coalesce-to-see-which-traversal-returns-a-result.md): Uses 'coalesce' to return the first traversal that yields a result, pairing it with 'constant', the 'fail' step, and use inside a 'by' modulator. - [Returning one of two possible results - introducing 'optional'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/returning-one-of-two-possible-results---introducing-optional.md): Returns a traversal result or the prior element with 'optional', shown as equivalent to 'coalesce' paired with an 'identity' step. - [Using 'V' and 'E' mid-traversal](https://krlawrence.github.io/graph/md/writing-gremlin-queries/using-v-and-e-mid-traversal.md): Uses 'V' and 'E' mid-traversal to launch fresh lookups, such as finding DFW routes longer than the longest route leaving IAD. - [Other ways to explore vertices and edges using 'both', 'bothE', 'bothV' and 'otherV'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/other-ways-to-explore-vertices-and-edges-using-both-bothe-bothv-and-otherv.md): Explores connections with 'both', 'bothE', 'bothV' and 'otherV', highlighting why 'bothE().bothV()' includes the start vertex while 'both' does not. - [Shortest paths (between airports) - introducing 'repeat'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/shortest-paths-between-airports---introducing-repeat.md): Finds paths with 'repeat' plus 'until', 'times', 'emit', 'simplePath' and 'cyclicPath', with nested repeats and warnings on path-finding memory cost. - [Calculating vertex degree](https://krlawrence.github.io/graph/md/writing-gremlin-queries/calculating-vertex-degree.md): Calculates in, out and overall vertex degree by counting edges and using 'group' or 'project' with 'bothE' to report route counts per airport. - [Gremlin’s scientific calculator – introducing 'math'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/gremlins-scientific-calculator--introducing-math.md): Performs arithmetic, trigonometry and standard-deviation math with the 'math' step, using the underscore symbol, labels, 'by' and 'project' to feed values. - [Including an index with results – introducing 'withIndex' and 'indexed'](https://krlawrence.github.io/graph/md/writing-gremlin-queries/including-an-index-with-results--introducing-withindex-and-indexed.md): Adds position counters with Groovy 'withIndex' and 'indexed' and the Gremlin 'index' step, using 'fold', 'WithOptions' and index values to reverse lists. - [More examples using concepts we have covered so far](https://krlawrence.github.io/graph/md/writing-gremlin-queries/more-examples-using-concepts-we-have-covered-so-far.md): Reinforces earlier steps with worked route queries, comparing 'as'/'select' against 'path'/'by' and using 'where', 'project' and 'order'. ## BEYOND BASIC QUERIES - [BEYOND BASIC QUERIES](https://krlawrence.github.io/graph/md/beyond-basic-queries/index.md): Introduces the chapter on creating, modifying, and deleting graph data, along with query layout, data modeling, and more advanced Gremlin techniques. - [A word about layout and indentation](https://krlawrence.github.io/graph/md/beyond-basic-queries/a-word-about-layout-and-indentation.md): Shows how to spread long Gremlin queries over multiple lines in the Console using backslash or trailing-period continuations, and mentions the Gremlint formatter. - [A word about idiomatic Gremlin](https://krlawrence.github.io/graph/md/beyond-basic-queries/a-word-about-idiomatic-gremlin.md): Discusses writing idiomatic Gremlin, favoring readable single-purpose steps like 'groupCount' and 'mergeV' that convey intent and let the database optimize. - [A warning about reserved word conflicts and collisions](https://krlawrence.github.io/graph/md/beyond-basic-queries/a-warning-about-reserved-word-conflicts-and-collisions.md): Explains how Gremlin steps like 'in', 'not', and 'as' clash with Groovy reserved words, and when the '.' prefix is needed to disambiguate. - [Thinking about your data model](https://krlawrence.github.io/graph/md/beyond-basic-queries/thinking-about-your-data-model.md): Offers graph data modeling advice, weighing vertices versus properties, storing data in two places for query efficiency, polyglot storage, and avoiding supernodes. - [Making Gremlin even Groovier](https://krlawrence.github.io/graph/md/beyond-basic-queries/making-gremlin-even-groovier.md): Shows how to mix Groovy into the Gremlin Console by defining methods, looping over query results, and using variables and 'fill' to feed further traversals. - [Adding vertices, edges, and properties](https://krlawrence.github.io/graph/md/beyond-basic-queries/adding-vertices-edges-and-properties.md): Covers adding vertices, edges, and properties with 'addV', 'addE', 'property', 'inject', 'repeat', and upserting via 'mergeV', 'mergeE', and 'coalesce'. - [Deleting vertices, edges, and properties](https://krlawrence.github.io/graph/md/beyond-basic-queries/deleting-vertices-edges-and-properties.md): Covers removing vertices, edges, and properties with 'drop', why steps after 'drop' do not run, and wrapping it in 'sideEffect' to drop and add together. - [Property keys and values revisited](https://krlawrence.github.io/graph/md/beyond-basic-queries/property-keys-and-values-revisited.md): Examines the 'Property' and 'VertexProperty' interfaces, property IDs, list and set cardinality, 'explain', meta-properties, and 'WithOptions' with 'valueMap'. - [Deducing the schema of a graph using queries](https://krlawrence.github.io/graph/md/beyond-basic-queries/deducing-the-schema-of-a-graph-using-queries.md): Uses queries with 'label', 'dedup', 'groupCount', and 'keys' to discover a graph's vertex and edge labels, property keys, and their data types. - [Collections revisited](https://krlawrence.github.io/graph/md/beyond-basic-queries/collections-revisited.md): Explores how 'group', 'groupCount', 'fold', 'project', and 'aggregate' build collections, and how to access, merge, and manipulate them with 'unfold' and 'local' scope. - [Collections and reducing barrier steps](https://krlawrence.github.io/graph/md/beyond-basic-queries/collections-and-reducing-barrier-steps.md): Explains reducing barrier steps like 'count', 'sum', and 'fold' that block access to earlier 'as' labels, and how to compute sums and averages with 'math'. - [Introducing 'sack' as a way to store values](https://krlawrence.github.io/graph/md/beyond-basic-queries/introducing-sack-as-a-way-to-store-values.md): Introduces the 'sack' step for carrying per-traverser values, using operators like 'sum', 'mult', 'min', 'max', 'addAll', and booleans to accumulate distances and hop counts. - [Using Lambda functions](https://krlawrence.github.io/graph/md/beyond-basic-queries/using-lambda-functions.md): Discusses using Groovy closures in steps like 'filter', 'map', 'flatMap', and 'sack', why lambdas are discouraged, and how 'map' differs from 'flatMap'. - [Turning graphs into trees](https://krlawrence.github.io/graph/md/beyond-basic-queries/turning-graphs-into-trees.md): Uses the 'tree' step with 'repeat' to build a depth-limited tree rooted at a vertex, then works with it via the TinkerPop Tree API. - [Creating a subgraph](https://krlawrence.github.io/graph/md/beyond-basic-queries/creating-a-subgraph.md): Shows how the 'subgraph' step extracts edges and their vertices into a new TinkerGraph, capped with 'cap' and queried through its own traversal source. - [Working with GraphML and GraphSON](https://krlawrence.github.io/graph/md/beyond-basic-queries/working-with-graphml-and-graphson.md): Covers saving and loading whole graphs as GraphML or GraphSON with the 'io' step, GraphSON versions and packaging, and rendering query results as JSON. - [Using null in Gremlin](https://krlawrence.github.io/graph/md/beyond-basic-queries/using-null-in-gremlin.md): Explains how null values flow through traversals, how 'property' with null removes or ignores properties, and null-safe behavior in graphs that support storing null. - [Understanding TraversalStrategies](https://krlawrence.github.io/graph/md/beyond-basic-queries/understanding-traversalstrategies.md): Explains TraversalStrategy types and covers verification strategies plus 'PartitionStrategy', 'SeedStrategy', and 'SubgraphStrategy' for filtering and determinism. - [Analyzing the performance of your queries](https://krlawrence.github.io/graph/md/beyond-basic-queries/analyzing-the-performance-of-your-queries.md): Demonstrates timing queries with 'clock' and 'clockWithResult', pinpointing costs with 'profile', and speeding lookups using TinkerGraph 'createIndex'. - [Using graph variables to associate metadata with TinkerGraph](https://krlawrence.github.io/graph/md/beyond-basic-queries/using-graph-variables-to-associate-metadata-with-tinkergraph.md): Shows how to attach metadata to a TinkerGraph using graph 'variables', setting, listing, retrieving, and removing key/value pairs with 'set', 'keys', 'asMap', 'get', and 'remove'. - [OLTP vs OLAP](https://krlawrence.github.io/graph/md/beyond-basic-queries/oltp-vs-olap.md): Contrasts OLTP and OLAP graph processing and demonstrates OLAP with the TinkerPop GraphComputer, running 'pageRank' and a PageRankVertexProgram on air-routes. - [Translating Gremlin to different programming languages](https://krlawrence.github.io/graph/md/beyond-basic-queries/translating-gremlin-to-different-programming-languages.md): Introduces gremlin-lang, the native grammar behind Gremlin, obtaining it via 'gremlinLang', and converting between languages using 'GremlinTranslator'. ## MISCELLANEOUS QUERIES AND THEIR RESULTS - [MISCELLANEOUS QUERIES AND THEIR RESULTS](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/index.md): Collects advanced OLTP-style example queries on the air-routes graph, showing route distribution, distance, and analysis techniques well suited to TinkerGraph. - [Counting more things](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/counting-more-things.md): Introduces a set of slightly more complex counting and distribution examples that build on techniques covered earlier in the book. - [Which countries have no airports?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/which-countries-have-no-airports.md): Identifies countries with no airports by finding 'country' vertices that have no outgoing edges via 'not', 'where', and 'out'. - [Which airports have no routes?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/which-airports-have-no-routes.md): Finds orphan airports with no commercial routes using 'not' on 'bothE('route')' and returning their codes with 'fold'. - [What is the distribution of runways?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/what-is-the-distribution-of-runways.md): Counts the per-airport distribution of runways with a simple 'groupCount' by 'runways', showing most airports have one or two. - [Airports with the most routes](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/airports-with-the-most-routes.md): Finds busiest airports using 'where' on route counts, then labels and sorts them with 'group' and 'order(local)', including combined inbound and outbound totals. - [Airports with just one route](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/airports-with-just-one-route.md): Counts the surprisingly many airports having exactly one outgoing route using 'where' with 'out().count()' and 'is(eq(1))'. - [Single runway airports with the most routes](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/single-runway-airports-with-the-most-routes.md): Lists the busiest single-runway airports with 'order' and 'project', using an 'or' step to include Gatwick despite its emergency-use second runway. - [Another way of counting runways](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/another-way-of-counting-runways.md): Turns a 'groupCount' of runways into a nicely labeled map by chaining 'unfold' and 'project' over 'keys' and 'values'. - [Airports with the most routes in Canada](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/airports-with-the-most-routes-in-canada.md): Ranks Canada's top ten airports by outgoing routes with 'order' and 'project', adding a one-based position via the 'index' method. - [Distribution of UK airports](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/distribution-of-uk-airports.md): Counts airports across England, Scotland, Wales, and Northern Ireland with a 'groupCount' by 'region' over the UK's 'contains' edges. - [Distribution of airports by country](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/distribution-of-airports-by-country.md): Builds airport-per-country distributions with 'groupCount', sorts them by values or keys with 'order(local)', and uses 'group' to include zero-airport countries. - [Distribution of routes per airport](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/distribution-of-routes-per-airport.md): Reports outgoing routes per airport with 'groupCount' and 'group', including selecting a numeric key through the Traversal form of 'select'. - [Using groupCount with a traversal variable](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/using-groupcount-with-a-traversal-variable.md): Explains that passing a variable to 'groupCount' makes it behave like 'sideEffect', storing counts without altering the traversal, retrieved later with 'select'. - [Combining 'groupCount' and 'constant'](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/combining-groupcount-and-constant.md): Shows how a 'constant' inside 'groupCount' sets the result key name, closing the named side-effect with 'cap'. - [Combining 'choose' and 'groupCount'](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/combining-choose-and-groupcount.md): Chains several 'choose' steps feeding a shared 'groupCount' variable to tally disparate airport counts in one traversal, with 'choose' acting like 'sideEffect'. - [Nesting one 'group' step inside another](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/nesting-one-group-step-inside-another.md): Shows how a 'group' step can nest inside another via its 'by' traversals, then drills into inner and outer results with 'select'. - [Analysis of routes between Europe and the USA](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/analysis-of-routes-between-europe-and-the-usa.md): Analyzes Europe-to-USA routes with 'count', 'dedup', and 'groupCount', profiling their distribution across US and European airports and listing sample paths with 'path'. - [Using 'fold' to do simple Map-Reduce computations](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/using-fold-to-do-simple-map-reduce-computations.md): Uses 'fold' to collect city names and, with a seed value and closure, to reduce them map-reduce style into a total character count. - [Distribution of routes in the graph (mode and mean)](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/distribution-of-routes-in-the-graph-mode-and-mean.md): Studies how routes distribute across airports with 'groupCount', revealing the statistical mode, and computes the mean using 'local' with the 'mean' step. - [How many routes are there from airports in London (UK)?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/how-many-routes-are-there-from-airports-in-london-uk.md): Counts outgoing routes from London airports with 'group', then uses 'aggregate' and 'without' to count destinations two hops away excluding London. - [How many routes are there between airports in England?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/how-many-routes-are-there-between-airports-in-england.md): Finds routes between English airports using 'aggregate' with 'within', and shows a 'where' comparison that returns each airport pair only once. - [What are the top ten airports by route count?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/what-are-the-top-ten-airports-by-route-count.md): Produces top-ten airport tables for incoming, outgoing, and total routes using 'order' by 'in', 'out', and 'both' counts with 'project'. - [Using 'local' while counting things](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/using-local-while-counting-things.md): Contrasts a plain 'fold' with wrapping it in 'local' so each airport's code and runway count is returned as its own paired list. - [How many vertices have no edges?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/how-many-vertices-have-no-edges.md): Counts vertices lacking outgoing, incoming, or any edges using 'not' with 'outE', 'inE', and 'bothE', plus an equivalent 'where' form. - [Where can I fly to from here?](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/where-can-i-fly-to-from-here.md): Answers where-can-I-fly questions, using 'repeat' with 'dedup' to test route existence and 'aggregate' with 'within' to find routes among selected cities. - [More analysis of distances between airports](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/more-analysis-of-distances-between-airports.md): Explores route distances by ordering on 'dist' with 'path', filtering return journeys, and using 'sack' to keep running totals for shortest multi-stop trips. - [Using latitude, longitude and geographical region in queries](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/using-latitude-longitude-and-geographical-region-in-queries.md): Writes geospatial queries on latitude and longitude with 'has', 'outside', and 'between', culminating in Great Circle distances computed via the 'math' step. - [Finding routes that go via a specific airport](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/finding-routes-that-go-via-a-specific-airport.md): Finds journeys passing through a chosen airport, first with a 'has' filter, then tracking a via-stop across 'repeat' hops using a 'sack' and 'choose'. - [Using 'store' and a 'sideEffect' to make a set of unique values](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/using-store-and-a-sideeffect-to-make-a-set-of-unique-values.md): Gathers unique values into a Set using 'withSideEffect' and 'aggregate' (store), comparing it with 'dedup' and extending it to collect related vertices and edges. - [Making a copy of the DFW vertex](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/making-a-copy-of-the-dfw-vertex.md): A case study copying the DFW vertex's label and properties with 'addV', 'select', and 'property', using 'sideEffect' and 'profile' to tame unwanted output. - [Modeling an ordered binary tree as a graph](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/modeling-an-ordered-binary-tree-as-a-graph.md): Builds an ordered binary tree graph and navigates it with 'repeat' and 'until' to find min and max values, plus the TinkerPop 'tree' API. - [Randomly walking a graph](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/randomly-walking-a-graph.md): Performs random graph walks using 'repeat' with 'sample' and 'otherV', starting from a fixed or random vertex, and 'local' to produce several independent walks. - [Seven degrees of separation!](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/seven-degrees-of-separation.md): Tests how many hops separate every airport from Heathrow using 'repeat', 'simplePath', and 'union', ultimately uncovering isolated subnetworks in the graph. - [Looking for the journey requiring the most stops](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/looking-for-the-journey-requiring-the-most-stops.md): Searches for airports needing the most hops to reach Austin using 'repeat' with 'emit' or 'until', filtering by path length and using 'dedup' for efficiency. - [Finding unwanted parallel edges](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/finding-unwanted-parallel-edges.md): Detects duplicate parallel edges by grouping vertex pairs with 'groupCount' and 'select', filtering counts over one, and also nesting 'path' inside 'groupCount'. - [Finding the longest flight route between two adjacent airports in the graph](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/finding-the-longest-flight-route-between-two-adjacent-airports-in-the-graph.md): A case study evolving a query for the longest single route, showing why 'max' loses paths and settling on 'aggregate', 'filter', and 'project'. - [Miscellaneous other queries](https://krlawrence.github.io/graph/md/miscellaneous-queries-and-their-results/miscellaneous-other-queries.md): Demonstrates using mathematical expressions and variables inside an 'is' step to filter airports by a computed route-count threshold. ## MOVING BEYOND THE GREMLIN CONSOLE - [MOVING BEYOND THE GREMLIN CONSOLE](https://krlawrence.github.io/graph/md/moving-beyond-the-gremlin-console/index.md): Moves beyond the Gremlin Console to interact with a TinkerGraph from Java and Groovy applications. ## INTRODUCING GREMLIN SERVER - [INTRODUCING GREMLIN SERVER](https://krlawrence.github.io/graph/md/introducing-gremlin-server/index.md): Explains how Gremlin Server exposes a graph behind a web server, hiding implementation details and letting non-TinkerPop languages query over HTTP. - [Configuring Gremlin Server](https://krlawrence.github.io/graph/md/introducing-gremlin-server/configuring-gremlin-server.md): Walks through editing 'gremlin-server.yaml', choosing the 'WsAndHttpChannelizer', tuning 'evaluationTimeout', and the init Groovy script to run a local TinkerGraph server. - [Loading air-routes In Gremlin Server](https://krlawrence.github.io/graph/md/introducing-gremlin-server/loading-air-routes-in-gremlin-server.md): Edits the 'empty-sample.groovy' init script to call 'TinkerFactory.generateAirRoutes' in 'onStartUp', loading air-routes data as the server boots. - [Connecting to a Gremlin Server from the Gremlin Console](https://krlawrence.github.io/graph/md/introducing-gremlin-server/connecting-to-a-gremlin-server-from-the-gremlin-console.md): Connects the console via 'remote.yaml', covering the ':' prefix, the 'result' variable in local mode, and toggling remote mode with ':remote console'. - [Connecting to a Gremlin Server from the command line](https://krlawrence.github.io/graph/md/introducing-gremlin-server/connecting-to-a-gremlin-server-from-the-command-line.md): Demonstrates querying a server with 'curl' over HTTP GET and the recommended POST, comparing the JSON returned with and without a 'valueMap' step. - [Connecting to a Gremlin Server from Java using 'with'](https://krlawrence.github.io/graph/md/introducing-gremlin-server/connecting-to-a-gremlin-server-from-java-using-with.md): Builds a Java 'RemoteClient' that uses 'Cluster', 'GraphBinaryMessageSerializerV1', and 'with' to bind a remote traversal source and get typed results. - [Connecting to a Gremlin Server from Ruby](https://krlawrence.github.io/graph/md/introducing-gremlin-server/connecting-to-a-gremlin-server-from-ruby.md): Shows a standalone Ruby program using only 'net/http' and 'json' to POST a Gremlin query and read the JSON response, no language binding required. - [Tweaking queries to make the JSON returned easier to work with](https://krlawrence.github.io/graph/md/introducing-gremlin-server/tweaking-queries-to-make-the-json-returned-easier-to-work-with.md): Reshapes verbose path JSON by appending 'toList().toString()', splitting, and parsing with Ruby's 'JSON' class to get clean per-route lists. - [More examples of the JSON returned from a Gremlin Server](https://krlawrence.github.io/graph/md/introducing-gremlin-server/more-examples-of-the-json-returned-from-a-gremlin-server.md): Catalogs the JSON shapes Gremlin Server returns for numbers, strings, lists, maps, vertices, edges, paths, and 'select' or 'project' results. ## COMMON GRAPH SERIALIZATION FORMATS - [COMMON GRAPH SERIALIZATION FORMATS](https://krlawrence.github.io/graph/md/common-graph-serialization-formats/index.md): Surveys common graph serialization formats, with a close look at the TinkerPop GraphSON (JSON) format. ## FURTHER READING - [FURTHER READING](https://krlawrence.github.io/graph/md/further-reading/index.md): Points to useful websites, tools, and documentation for continued learning about Apache TinkerPop and Gremlin.