# Network Theory and Switching Behaviors: A User Guide for Analyzing Electronic Records Databases
## 2 Fundamentals of Graph Theory  
In this section, we will provide a very basic introduction to the fundamental concepts of graph theory. We will avoid a formal approach in favor of a more discursive presentation in order to allow researchers without a mathematical background (or mathematical aptitude) to easily understand this topic. A formal introduction can be found in the books of [PERSON] et al. (2018) or [PERSON] (2018). From a mathematical point of view, a network (also called graph) consists of a set of nodes (or vertices) and a set of connections between nodes, the edges (or links). A network can be either directed or undirected. A directed network is characterized by edges that point in only one direction (from a node to another node). When links between edges are not oriented in a specific direction (i.e., they are generic connections), the network is an undirected network. In this paper, we will deal with directed networks, which represent an ideal approach to model switching behaviors. Calling V the set of nodes and E the set of edges, a graph G can be defined as a pair G = (V, E). In a directed graph, E is the set of ordered pairs of vertices (that is, an edge is associated with two distinct nodes). A graph can be represented by using an adjacency matrix A, a square n x n matrix, where n is the number of nodes. Each element Ai,j is different from zero if node i is connected to node j by an edge in the graph. The value of each element of the matrix represents the weight of the connection between two nodes. Because we are considering directed graphs, it is necessary to specify that weights stand for the link from the starting node (reported on rows, for example) to the destination node (thus reported on the columns in this example). Adjacency matrices of directed graphs can be asymmetric of course, and in the case of recurrent connections on the same node, the main diagonal elements may be nonzero. Within the study of network topology, several measures can be defined. First, it is necessary to clarify the meaning of some terms. A walk is a sequence (finite or infinite) of links that joins a sequence of nodes. A walk, in which all links are distinct is called a trail. Finally, a trail, in which all nodes (and thus all edges) are distinct is defined as a path. The distance between two nodes is the length of the shortest directed (in the case of a directed graph, as the case object of this study) path. Of course, there may be more than a single shortest path between two nodes. In order to evaluate the structure of a graph, the average path length that is the mean value of the shortest paths for all possible pairs of graph vertices can be computed. Generally, it is considered an efficiency measure of the information flow of the network. Taking into account the distance between each pair of vertices, the greatest length of any of these paths is called the diameter of the network. In a directed graph, each node is characterized by the in-degree value (the number of incoming links) and an out-degree (the number of outgoing links). The centrality degree values represent a sort of popularity index ([PERSON] et al., 2018). As the number of incoming links (or outgoing, in other cases) increases, the importance of a node within the network increases too. Other useful measures are the node betweenness centrality and closeness. Node betweenness centrality allows understanding the importance of a node in the \"flow management\" of the network. Indeed, the interaction between two nonadjacent nodes A and B is related to the nodes placed on the path between A and B. Node betweenness centrality of a node X is the ratio between the number of shortest paths (between any pair of vertices in the network) that passes through X and the total number of shortest paths existing between any couple of nodes in the network. The closeness of a node W is the reciprocal of the sum of every shortest path between node W and all other nodes in the graph. High values of closeness indicate that node W is \"near\" to all other nodes.