Types of graphs
The primary graph types are undirected, directed, and weighted graphs, as illustrated in Figure 6.4. Social networks can be undirected as well as directed graphs. In the former, edges end up being unordered pairs, for example, Facebook. In the latter, edges are ordered pairs, for example, Twitter, in which one node is an origin and the other a destination.
Figure 6.4: Three standard graph types
We will explore each of these graphs in the following subsections.
Undirected graphs
While solving a problem using graph theory, the first step is to determine the type of graph we are dealing with. In undirected graphs, there is no particular direction of the edges between nodes, in other words, the edge is bidirectional. An edge connecting node 1 to node 2 (Figure 6.5) would be identical to the edge connecting node 2 to node 1.
Figure 6.5: Directed and undirected graphs