social network of fifty people. Each person on the network is represented by an integer. The social network is represented as a matrix . If person and are "friends" then, else . . How many mutual friends do the two people with the least number of mutual friends have?
Consider this miniDetails and Assumptions
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Two people have a mutual friend when they both have a "1" corresponding to that person. Multipling two peoples' rows together will thus produce a "1" for each mutual friend and a "0" for each non-mutual friend (1*0) and "0" for friends neither has. The matrix is symmetric because if a person A is a friend of person B then person B is a friend of person A. This allows us to multiply the matrix by itself, then sum across the rows or columns. The lowest sum is the lowest number of mutual friends.
in Excel: Place the matrix in A1-AX50. Then use mmult(A1:AX50,A1,AX50). Sum the columns of the resulting matrix and find the minimum of the sums.
In Matlab: If the friend matrix is M, then N=M^2; min(sum(N))