Question: MATLAB coding end Maximum Clique Given a social network, find the largest clique, that is, the largest subset of people who alt follow each other.
end Maximum Clique Given a social network, find the largest clique, that is, the largest subset of people who alt follow each other. The data structure that contains the social network is set up as follows: People in the social network are identified by unique IDs, consecutive integers from 1 to N Who follows who is captured in a cell array called sn: the ith element of an is a vector that contains a list of IDs the person with ID follows. You may assume that these lists are ordered in ascending order by ID. Note that the follows relationship is not necessarily symmetrical person A follows person B, person may or may not follow person A. Here is one possible recursive) implementation: function clique = max_clique(graph, clique) if nargin tength(max_cla) if the new one is targer than the current max_cla = cler we store the new one end end else for node-1: length(graph) we are in a recursive call now we test every node as a new member 1 isempty(find (node = clique)) unless it is already in the clique if check_clique clique, node, graph) if adding this node is still actique clq = max cliquegraph, Iclique node]): we call ourself with the new expanded cuique If length(ca) > length(max_cla) if what we get is larger the curent max max_cla cta; we store the new one end end end end end clique - max.clo: return the largest one end function ok check_clique cla, nodegraph) adding node to cla sitt a clique? ok = false; for 11 = 1: length(cla) for every current member if isempty(find clit) - graph node))) 11 ... the member must be the follows list of the new guy isempty(findinode = graph(cla(11) >>) the new guy must be on the follows list of the senber return; end end ok = true; end Unfortunately, it is too slow and the grader will time out. Your task is to modity the code to speed it up. Remember the question to ask am doing any unincessary work? Call the modified function max_clique (Hint: when we try to expand the current clique, do we really need to consider all the nodes?) Here is the mat tile with the example social network: smat
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
