In this section, we are going to implement a simplified version of Label Propagation, considering seed labels can only take two different values: 0 or 1.
We will use the same graph representation as in the previous chapters, based on a Python dictionary. The graph we will use is represented by the following object:
G = {
'A': {'B': 1, 'C': 1},
'B': {'A': 1, 'C': 1},
'C': {'A': 1, 'B': 1, 'D': 1},
'D': {'C': 1, 'E': 1, 'G': 1},
'E': {'D': 1, 'F': 1, 'G': 1},
'F': {'E': 1, 'G': 1},
'G': {'D': 1, 'E': 1, 'F': 1},
}
It tells us that node A is connected to nodes B and C, both edges having a weight equal to 1.
Let's now start the algorithm. In the...