This chapter covers:
- Math and text representation of graphs
- Introducing graph databases
- Labeled-property graph model schema design
- Extracting information from text
In the previous chapter, you learned the basics of graph theory. Before you dig more into practical network analysis, you first have to learn how to practically represent network structures. The most basic graph representation is the mathematical data structure adjacency matrix.
Figure 2.1. Adjacency matrix representing a network structure

An adjacency matrix is a square matrix, where the matrix elements indicate whether pairs of nodes are connected or not in the graph. The adjancency matrix dimensions are equal to the number of nodes in the graph. It can also be expanded to represent weighted graphs. Instead of having zeroes indicating the presence of the relationships, you store the relationship weight as the matrix element. You will not be using it in the examples of this book, but you can check out the adjacency matrix appendix if you want to learn more. Another mathematical structure to represent networks is called the edge list data structure.
Figure 2.2. A directed unweighted graph represented with a edge list data structure
