A graph is a just a collection of vertices and edges. The most convincing example of a graph-data model is a social network. Each piece of information in this world is connected. To store and process information correctly, a database must embrace and store the entity and its connectivity with another entity. This is where the graph-data model kicks in. Storing and accessing nodes and relationships in a graph database is an easy, efficient, and constant-time operation that permits a user to quickly traverse and get correct information.
Mathematically, a graph is a pair G = (V, E) of sets that satisfy E ( V X V). The elements of V are the vertices or nodes of the graph, G, and the elements of E are its edges or relationships.
Let's see a graph model of movies and actors.
Figure 5.6: Labeled graph model of movies and actors
From the movie data model given...