3 Running basic and recursive traversals

 

This chapter covers

  • Navigating the structure of a graph
  • Performing filtering operations with traversals
  • Using recursive traversals

With our graph data model in hand, the next three chapters focus on how to navigate through our graph and how to return data. In this chapter, we’ll start by filtering and navigating edges, the fundamental building blocks of graph traversals. We then extend these concepts to cover a powerful feature of graphs: the ability to easily write recursive queries. Additionally, we examine how to leverage these techniques to answer common graph questions, such as how people are connected in social networks.

Throughout these next three chapters, we’ll use the social network use case defined in chapter 2. As we move through this process, we’ll use Gremlin as our query language and introduce its syntax, known as steps. Don’t worry if you don’t know Gremlin or are using a different language; we’ll thoroughly explain each step as we encounter it. Although we cover quite a few Gremlin steps throughout this chapter, you can refer to the Apache TinkerPop official documentation on Gremlin for a more thorough explanation (http://tinkerpop.apache.org/docs/current/reference/).

3.1 Setting up your environment

3.1.1 Starting the Gremlin Server

3.1.2 Starting the Gremlin Console, connecting to the Gremlin Server, and loading the data

3.2 Traversing a graph

3.2.1 Using a logical data model (schema) to plan traversals

3.2.2 Planning the steps through the graph data

3.2.3 Fundamental concepts of traversing a graph

3.2.4 Writing traversals in Gremlin

3.2.5 Retrieving properties with values steps

3.3 Recursive traversals

3.3.1 Using recursive logic

3.3.2 Writing recursive traversals in Gremlin

Summary