I am writing machine learning code in MATLAB, and I am presenting a graph with adjacency matrix A and clustering a graph with matrix Z defined in the following ways.
A: a_ij is 1 if there is an edge between node i and node j. 0 otherwise. Z: z_ij is 1 if node j is in cluster i. 0 otherwise.
I compute the matrix N, which is the number of edges between clusters, defined as follows:
N: n_ij is the number of edges between nodes in cluster i and nodes in cluster j. n_ii is the number of edges within cluster i.
N can be calculated:
N = zAz'
where z is z-transposed.
If I have many nodes, then the calculation takes some time, but this is not a problem. The problem is that I move nodes from cluster to cluster many times, and every time I want to calculate N.
So, the problem is this: given that I know N, and then I move node I from cluster c_1 to cluster c_2, how can I effectively update N?
source share