To work on a graph and simulate information spread within it, we need a way to model the complex relationship pattern. The simplest way of doing so is to build the adjacency matrix of the graph. It is a 2D array where the element on line i and column j is equal to 1 if there is an edge going from node i to node j and 0 otherwise.
The adjacency matrix of the graph we studied during the implementation of the PageRank algorithm is as follows:
The first element of the first row corresponds to the edge between A and A. Since A is not connected to itself, this element is 0. The second element of the first row holds information about the edge between A and B. Since there is a relationship between these two nodes, this element is equal to 1. Similarly, the second row of the adjacency matrix contains information about the outgoing edges from node B. This node has a single outgoing edge going to A. A corresponds to the first column of the matrix, so only the first element...