{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":2730,"title":"Graph Algorithms 3: Number of Connected Components","description":"Given an adjacency matrix of a simple undirected graph, find the number of connected components.","description_html":"\u003cp\u003eGiven an adjacency matrix of a simple undirected graph, find the number of connected components.\u003c/p\u003e","function_template":"function y = cComponents(x)\r\n  y = x;\r\nend","test_suite":"%%\r\na = ones(3) - eye(3);\r\nb = zeros(3);\r\nmat = [a b; b a];\r\nn = 2;\r\nassert(isequal(cComponents(mat),n))\r\n\r\n\r\n%%\r\na = randi(20);\r\nmat = ones(a) - eye(a);\r\nn = 1;\r\nassert(isequal(cComponents(mat),n))\r\n\r\n\r\n%%\r\nmat = [0 1 0 0 1;\r\n       1 0 1 0 0;\r\n       0 1 0 1 0;\r\n       0 0 1 0 1;\r\n       1 0 0 1 0];\r\nassert(isequal(cComponents(mat),1))\r\n\r\n\r\n%%\r\na = ones(3) - eye(3);\r\nb = zeros(3);\r\nmat = [a b b; b a b; b b a];\r\nn = 3;\r\nassert(isequal(cComponents(mat),n))\r\n\r\n\r\n%%\r\na = ones(3) - eye(3);\r\nb = zeros(3);\r\np = floor((randi(20)+3)/3)*3;\r\nmat = [];\r\nfor i= 1:p\r\n    c = [repmat(b,1,i-1) a repmat(b,1,p-i)];\r\n    mat = [mat;c];\r\nend\r\n\r\nassert(isequal(cComponents(mat),p))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":40,"test_suite_updated_at":"2014-12-07T06:39:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-06T07:19:29.000Z","updated_at":"2026-03-30T17:12:13.000Z","published_at":"2014-12-06T07:19:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an adjacency matrix of a simple undirected graph, find the number of connected components.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2646,"title":"Determine the number of maximal cliques in an undirected graph","description":"In an undirected graph, a clique is a subset of vertices that are fully connected, i.e. there is an edge between all pairs of vertices in the subset. A _maximal_ clique is one in which the subset of vertices is not part of a larger clique. So, for instance, a fully connected graph has many cliques, but only one maximal clique.\r\n\r\nGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return the number (num) of maximal cliques.\r\n\r\n*Example*\r\n\r\nConsider the graph shown below,\r\n\r\n\u003c\u003chttps://dl.dropboxusercontent.com/u/13345152/examplegraph.png\u003e\u003e\r\n\r\nwhich has the following adjacency matrix:\r\n\r\n  A = [ 0 1 0 0 0\r\n        1 0 1 1 0\r\n        0 1 0 1 0\r\n        0 1 1 0 1\r\n        0 0 0 1 0 ]\r\n\r\nThe number of maximal cliques is 3. The maximal cliques are {1,2}, {2,3,4}, and {4,5}.\r\n\r\nNOTE: You may assume the data type of the adjacency matrix is double.","description_html":"\u003cp\u003eIn an undirected graph, a clique is a subset of vertices that are fully connected, i.e. there is an edge between all pairs of vertices in the subset. A \u003ci\u003emaximal\u003c/i\u003e clique is one in which the subset of vertices is not part of a larger clique. So, for instance, a fully connected graph has many cliques, but only one maximal clique.\u003c/p\u003e\u003cp\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return the number (num) of maximal cliques.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eConsider the graph shown below,\u003c/p\u003e\u003cimg src = \"https://dl.dropboxusercontent.com/u/13345152/examplegraph.png\"\u003e\u003cp\u003ewhich has the following adjacency matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ]\r\n\u003c/pre\u003e\u003cp\u003eThe number of maximal cliques is 3. The maximal cliques are {1,2}, {2,3,4}, and {4,5}.\u003c/p\u003e\u003cp\u003eNOTE: You may assume the data type of the adjacency matrix is double.\u003c/p\u003e","function_template":"function num = maximalcliques(A)\r\n  num = 0;\r\nend","test_suite":"%%\r\nA = 0;\r\nassert(isequal(maximalcliques(A),1))\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = ones(N)-eye(N);\r\n  assert(isequal(maximalcliques(A),1))\r\nend\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = zeros(N);\r\n  assert(isequal(maximalcliques(A),N))\r\nend\r\n\r\n%%\r\nA = [ 0 0 0 0\r\n      0 0 0 1\r\n      0 0 0 0\r\n      0 1 0 0 ];\r\nassert(isequal(maximalcliques(A),3))\r\n\r\n%%\r\nA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ];\r\nassert(isequal(maximalcliques(A),3))\r\n\r\n%%\r\nA = [ 0 1 1 0 0 0\r\n      1 0 1 1 0 0\r\n      1 1 0 0 1 0\r\n      0 1 0 0 1 0\r\n      0 0 1 1 0 1\r\n      0 0 0 0 1 0 ];\r\nassert(isequal(maximalcliques(A),5))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":"2014-10-28T21:35:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-10-28T21:07:46.000Z","updated_at":"2014-10-28T22:05:37.000Z","published_at":"2014-10-28T21:35:49.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.png\"}],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn an undirected graph, a clique is a subset of vertices that are fully connected, i.e. there is an edge between all pairs of vertices in the subset. A\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emaximal\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e clique is one in which the subset of vertices is not part of a larger clique. So, for instance, a fully connected graph has many cliques, but only one maximal clique.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return the number (num) of maximal cliques.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider the graph shown below,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich has the following adjacency matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A = [ 0 1 0 0 0\\n      1 0 1 1 0\\n      0 1 0 1 0\\n      0 1 1 0 1\\n      0 0 0 1 0 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe number of maximal cliques is 3. The maximal cliques are {1,2}, {2,3,4}, and {4,5}.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNOTE: You may assume the data type of the adjacency matrix is double.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAADAFBMVEV4eHiTk5P29vaBgYGcnJzAwMC3t7eKiorS0tLt7e3b29vk5OTJycn///9vb28AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD61b95AAAAyklEQVR42q2SSQ6FIAxAWzQxkcj976lEE5R+hojQOmw+Cxa8RwcoGnhf6oNDD0AvGL8j/E2wC+JiXwSaAKbbatGkLjBrX13szynmtPXnKc2eCRiMGQtXxrq2hmZRuuXx6SVdPlPpopeC387sFMMIwdsyAMFAEcHuptW5oIaKYgjHBBoZ512snMeJ8g7o0DmA5jwKXRdqy9W6gfMzhd7iMOySlxq0qn/z4leR43HNQ8WrLtYi1Dz+pnjsmt/8ZsulwLgQOOeC4EyQHH5z1GUZiLNTtwAAAABJRU5ErkJggg==\"}]}"},{"id":2647,"title":"Find the maximal cliques in an undirected graph","description":"This is a variant of a \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2646-determine-the-number-of-maximal-cliques-in-an-undirected-graph previous problem\u003e on maximal cliques. Instead of simply computing the number of maximal cliques in an undirected graph, now you must return the cliques themselves.\r\n\r\nGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return an array (C) in which each column encodes one of the maximal cliques in the graph. If C(i,j) = 1, then the ith vertex in the graph is included in the jth clique. The order of columns does not matter, but all maximal cliques must be given - that is, size(C,2) should equal the number of maximal cliques.\r\n\r\n*Example*\r\n\r\nConsider the graph shown below,\r\n\r\n\u003c\u003chttps://dl.dropboxusercontent.com/u/13345152/examplegraph.png\u003e\u003e\r\n\r\nwhich has the following adjacency matrix:\r\n\r\n  A = [ 0 1 0 0 0\r\n        1 0 1 1 0\r\n        0 1 0 1 0\r\n        0 1 1 0 1\r\n        0 0 0 1 0 ]\r\n\r\nThe maximal cliques are {1,2}, {2,3,4}, and {4,5}. Therefore, one (of three) valid outputs is:\r\n\r\n  C = [ 1 0 0\r\n        1 1 0\r\n        0 1 0\r\n        0 1 1\r\n        0 0 1 ]\r\n\r\nNOTE: You may assume the data type of the adjacency matrix (A) is double.","description_html":"\u003cp\u003eThis is a variant of a \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2646-determine-the-number-of-maximal-cliques-in-an-undirected-graph\"\u003eprevious problem\u003c/a\u003e on maximal cliques. Instead of simply computing the number of maximal cliques in an undirected graph, now you must return the cliques themselves.\u003c/p\u003e\u003cp\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return an array (C) in which each column encodes one of the maximal cliques in the graph. If C(i,j) = 1, then the ith vertex in the graph is included in the jth clique. The order of columns does not matter, but all maximal cliques must be given - that is, size(C,2) should equal the number of maximal cliques.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eConsider the graph shown below,\u003c/p\u003e\u003cimg src = \"https://dl.dropboxusercontent.com/u/13345152/examplegraph.png\"\u003e\u003cp\u003ewhich has the following adjacency matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ]\r\n\u003c/pre\u003e\u003cp\u003eThe maximal cliques are {1,2}, {2,3,4}, and {4,5}. Therefore, one (of three) valid outputs is:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eC = [ 1 0 0\r\n      1 1 0\r\n      0 1 0\r\n      0 1 1\r\n      0 0 1 ]\r\n\u003c/pre\u003e\u003cp\u003eNOTE: You may assume the data type of the adjacency matrix (A) is double.\u003c/p\u003e","function_template":"function C = maximalcliques(A)\r\n  C = [];\r\nend","test_suite":"%%\r\nA = 0;\r\nassert(isequal(maximalcliques(A),1))\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = ones(N)-eye(N);\r\n  assert(isequal(maximalcliques(A),ones(N,1)))\r\nend\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = zeros(N);\r\n  C = maximalcliques(A);\r\n  assert(isequal(fliplr(sortrows(C')'),eye(N)))\r\nend\r\n\r\n%%\r\nA = [ 0 0 0 0\r\n      0 0 0 1\r\n      0 0 0 0\r\n      0 1 0 0 ];\r\nC = maximalcliques(A);\r\nC = fliplr(sortrows(C')');\r\nC_correct = [ 1 0 0\r\n              0 1 0\r\n              0 0 1\r\n              0 1 0 ];\r\nassert(isequal(C,C_correct))\r\n\r\n%%\r\nA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ];\r\nC = maximalcliques(A);\r\nC = fliplr(sortrows(C')');\r\nC_correct = [ 1 0 0\r\n              1 1 0\r\n              0 1 0\r\n              0 1 1\r\n              0 0 1 ];\r\nassert(isequal(C,C_correct))\r\n\r\n%%\r\nA = [ 0 1 1 0 0 0\r\n      1 0 1 1 0 0\r\n      1 1 0 0 1 0\r\n      0 1 0 0 1 0\r\n      0 0 1 1 0 1\r\n      0 0 0 0 1 0 ];\r\nC = maximalcliques(A);\r\nC = fliplr(sortrows(C')');\r\nC_correct = [ 1 0 0 0 0\r\n              1 1 0 0 0\r\n              1 0 1 0 0\r\n              0 1 0 1 0\r\n              0 0 1 1 1\r\n              0 0 0 0 1 ];\r\nassert(isequal(C,C_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2014-10-28T22:05:02.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-10-28T21:53:54.000Z","updated_at":"2014-10-28T22:05:02.000Z","published_at":"2014-10-28T22:05:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.png\"}],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is a variant of a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2646-determine-the-number-of-maximal-cliques-in-an-undirected-graph\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eprevious problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e on maximal cliques. Instead of simply computing the number of maximal cliques in an undirected graph, now you must return the cliques themselves.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return an array (C) in which each column encodes one of the maximal cliques in the graph. If C(i,j) = 1, then the ith vertex in the graph is included in the jth clique. The order of columns does not matter, but all maximal cliques must be given - that is, size(C,2) should equal the number of maximal cliques.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider the graph shown below,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich has the following adjacency matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A = [ 0 1 0 0 0\\n      1 0 1 1 0\\n      0 1 0 1 0\\n      0 1 1 0 1\\n      0 0 0 1 0 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe maximal cliques are {1,2}, {2,3,4}, and {4,5}. Therefore, one (of three) valid outputs is:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[C = [ 1 0 0\\n      1 1 0\\n      0 1 0\\n      0 1 1\\n      0 0 1 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNOTE: You may assume the data type of the adjacency matrix (A) is double.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAADAFBMVEV4eHiTk5P29vaBgYGcnJzAwMC3t7eKiorS0tLt7e3b29vk5OTJycn///9vb28AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD61b95AAAAyklEQVR42q2SSQ6FIAxAWzQxkcj976lEE5R+hojQOmw+Cxa8RwcoGnhf6oNDD0AvGL8j/E2wC+JiXwSaAKbbatGkLjBrX13szynmtPXnKc2eCRiMGQtXxrq2hmZRuuXx6SVdPlPpopeC387sFMMIwdsyAMFAEcHuptW5oIaKYgjHBBoZ512snMeJ8g7o0DmA5jwKXRdqy9W6gfMzhd7iMOySlxq0qn/z4leR43HNQ8WrLtYi1Dz+pnjsmt/8ZsulwLgQOOeC4EyQHH5z1GUZiLNTtwAAAABJRU5ErkJggg==\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":2730,"title":"Graph Algorithms 3: Number of Connected Components","description":"Given an adjacency matrix of a simple undirected graph, find the number of connected components.","description_html":"\u003cp\u003eGiven an adjacency matrix of a simple undirected graph, find the number of connected components.\u003c/p\u003e","function_template":"function y = cComponents(x)\r\n  y = x;\r\nend","test_suite":"%%\r\na = ones(3) - eye(3);\r\nb = zeros(3);\r\nmat = [a b; b a];\r\nn = 2;\r\nassert(isequal(cComponents(mat),n))\r\n\r\n\r\n%%\r\na = randi(20);\r\nmat = ones(a) - eye(a);\r\nn = 1;\r\nassert(isequal(cComponents(mat),n))\r\n\r\n\r\n%%\r\nmat = [0 1 0 0 1;\r\n       1 0 1 0 0;\r\n       0 1 0 1 0;\r\n       0 0 1 0 1;\r\n       1 0 0 1 0];\r\nassert(isequal(cComponents(mat),1))\r\n\r\n\r\n%%\r\na = ones(3) - eye(3);\r\nb = zeros(3);\r\nmat = [a b b; b a b; b b a];\r\nn = 3;\r\nassert(isequal(cComponents(mat),n))\r\n\r\n\r\n%%\r\na = ones(3) - eye(3);\r\nb = zeros(3);\r\np = floor((randi(20)+3)/3)*3;\r\nmat = [];\r\nfor i= 1:p\r\n    c = [repmat(b,1,i-1) a repmat(b,1,p-i)];\r\n    mat = [mat;c];\r\nend\r\n\r\nassert(isequal(cComponents(mat),p))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":40,"test_suite_updated_at":"2014-12-07T06:39:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-06T07:19:29.000Z","updated_at":"2026-03-30T17:12:13.000Z","published_at":"2014-12-06T07:19:28.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an adjacency matrix of a simple undirected graph, find the number of connected components.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2646,"title":"Determine the number of maximal cliques in an undirected graph","description":"In an undirected graph, a clique is a subset of vertices that are fully connected, i.e. there is an edge between all pairs of vertices in the subset. A _maximal_ clique is one in which the subset of vertices is not part of a larger clique. So, for instance, a fully connected graph has many cliques, but only one maximal clique.\r\n\r\nGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return the number (num) of maximal cliques.\r\n\r\n*Example*\r\n\r\nConsider the graph shown below,\r\n\r\n\u003c\u003chttps://dl.dropboxusercontent.com/u/13345152/examplegraph.png\u003e\u003e\r\n\r\nwhich has the following adjacency matrix:\r\n\r\n  A = [ 0 1 0 0 0\r\n        1 0 1 1 0\r\n        0 1 0 1 0\r\n        0 1 1 0 1\r\n        0 0 0 1 0 ]\r\n\r\nThe number of maximal cliques is 3. The maximal cliques are {1,2}, {2,3,4}, and {4,5}.\r\n\r\nNOTE: You may assume the data type of the adjacency matrix is double.","description_html":"\u003cp\u003eIn an undirected graph, a clique is a subset of vertices that are fully connected, i.e. there is an edge between all pairs of vertices in the subset. A \u003ci\u003emaximal\u003c/i\u003e clique is one in which the subset of vertices is not part of a larger clique. So, for instance, a fully connected graph has many cliques, but only one maximal clique.\u003c/p\u003e\u003cp\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return the number (num) of maximal cliques.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eConsider the graph shown below,\u003c/p\u003e\u003cimg src = \"https://dl.dropboxusercontent.com/u/13345152/examplegraph.png\"\u003e\u003cp\u003ewhich has the following adjacency matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ]\r\n\u003c/pre\u003e\u003cp\u003eThe number of maximal cliques is 3. The maximal cliques are {1,2}, {2,3,4}, and {4,5}.\u003c/p\u003e\u003cp\u003eNOTE: You may assume the data type of the adjacency matrix is double.\u003c/p\u003e","function_template":"function num = maximalcliques(A)\r\n  num = 0;\r\nend","test_suite":"%%\r\nA = 0;\r\nassert(isequal(maximalcliques(A),1))\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = ones(N)-eye(N);\r\n  assert(isequal(maximalcliques(A),1))\r\nend\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = zeros(N);\r\n  assert(isequal(maximalcliques(A),N))\r\nend\r\n\r\n%%\r\nA = [ 0 0 0 0\r\n      0 0 0 1\r\n      0 0 0 0\r\n      0 1 0 0 ];\r\nassert(isequal(maximalcliques(A),3))\r\n\r\n%%\r\nA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ];\r\nassert(isequal(maximalcliques(A),3))\r\n\r\n%%\r\nA = [ 0 1 1 0 0 0\r\n      1 0 1 1 0 0\r\n      1 1 0 0 1 0\r\n      0 1 0 0 1 0\r\n      0 0 1 1 0 1\r\n      0 0 0 0 1 0 ];\r\nassert(isequal(maximalcliques(A),5))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":"2014-10-28T21:35:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-10-28T21:07:46.000Z","updated_at":"2014-10-28T22:05:37.000Z","published_at":"2014-10-28T21:35:49.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.png\"}],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn an undirected graph, a clique is a subset of vertices that are fully connected, i.e. there is an edge between all pairs of vertices in the subset. A\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003emaximal\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e clique is one in which the subset of vertices is not part of a larger clique. So, for instance, a fully connected graph has many cliques, but only one maximal clique.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return the number (num) of maximal cliques.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider the graph shown below,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich has the following adjacency matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A = [ 0 1 0 0 0\\n      1 0 1 1 0\\n      0 1 0 1 0\\n      0 1 1 0 1\\n      0 0 0 1 0 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe number of maximal cliques is 3. The maximal cliques are {1,2}, {2,3,4}, and {4,5}.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNOTE: You may assume the data type of the adjacency matrix is double.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAADAFBMVEV4eHiTk5P29vaBgYGcnJzAwMC3t7eKiorS0tLt7e3b29vk5OTJycn///9vb28AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD61b95AAAAyklEQVR42q2SSQ6FIAxAWzQxkcj976lEE5R+hojQOmw+Cxa8RwcoGnhf6oNDD0AvGL8j/E2wC+JiXwSaAKbbatGkLjBrX13szynmtPXnKc2eCRiMGQtXxrq2hmZRuuXx6SVdPlPpopeC387sFMMIwdsyAMFAEcHuptW5oIaKYgjHBBoZ512snMeJ8g7o0DmA5jwKXRdqy9W6gfMzhd7iMOySlxq0qn/z4leR43HNQ8WrLtYi1Dz+pnjsmt/8ZsulwLgQOOeC4EyQHH5z1GUZiLNTtwAAAABJRU5ErkJggg==\"}]}"},{"id":2647,"title":"Find the maximal cliques in an undirected graph","description":"This is a variant of a \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2646-determine-the-number-of-maximal-cliques-in-an-undirected-graph previous problem\u003e on maximal cliques. Instead of simply computing the number of maximal cliques in an undirected graph, now you must return the cliques themselves.\r\n\r\nGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return an array (C) in which each column encodes one of the maximal cliques in the graph. If C(i,j) = 1, then the ith vertex in the graph is included in the jth clique. The order of columns does not matter, but all maximal cliques must be given - that is, size(C,2) should equal the number of maximal cliques.\r\n\r\n*Example*\r\n\r\nConsider the graph shown below,\r\n\r\n\u003c\u003chttps://dl.dropboxusercontent.com/u/13345152/examplegraph.png\u003e\u003e\r\n\r\nwhich has the following adjacency matrix:\r\n\r\n  A = [ 0 1 0 0 0\r\n        1 0 1 1 0\r\n        0 1 0 1 0\r\n        0 1 1 0 1\r\n        0 0 0 1 0 ]\r\n\r\nThe maximal cliques are {1,2}, {2,3,4}, and {4,5}. Therefore, one (of three) valid outputs is:\r\n\r\n  C = [ 1 0 0\r\n        1 1 0\r\n        0 1 0\r\n        0 1 1\r\n        0 0 1 ]\r\n\r\nNOTE: You may assume the data type of the adjacency matrix (A) is double.","description_html":"\u003cp\u003eThis is a variant of a \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/2646-determine-the-number-of-maximal-cliques-in-an-undirected-graph\"\u003eprevious problem\u003c/a\u003e on maximal cliques. Instead of simply computing the number of maximal cliques in an undirected graph, now you must return the cliques themselves.\u003c/p\u003e\u003cp\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return an array (C) in which each column encodes one of the maximal cliques in the graph. If C(i,j) = 1, then the ith vertex in the graph is included in the jth clique. The order of columns does not matter, but all maximal cliques must be given - that is, size(C,2) should equal the number of maximal cliques.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eConsider the graph shown below,\u003c/p\u003e\u003cimg src = \"https://dl.dropboxusercontent.com/u/13345152/examplegraph.png\"\u003e\u003cp\u003ewhich has the following adjacency matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ]\r\n\u003c/pre\u003e\u003cp\u003eThe maximal cliques are {1,2}, {2,3,4}, and {4,5}. Therefore, one (of three) valid outputs is:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eC = [ 1 0 0\r\n      1 1 0\r\n      0 1 0\r\n      0 1 1\r\n      0 0 1 ]\r\n\u003c/pre\u003e\u003cp\u003eNOTE: You may assume the data type of the adjacency matrix (A) is double.\u003c/p\u003e","function_template":"function C = maximalcliques(A)\r\n  C = [];\r\nend","test_suite":"%%\r\nA = 0;\r\nassert(isequal(maximalcliques(A),1))\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = ones(N)-eye(N);\r\n  assert(isequal(maximalcliques(A),ones(N,1)))\r\nend\r\n\r\n%%\r\nfor ii=1:10\r\n  N = randi(100);\r\n  A = zeros(N);\r\n  C = maximalcliques(A);\r\n  assert(isequal(fliplr(sortrows(C')'),eye(N)))\r\nend\r\n\r\n%%\r\nA = [ 0 0 0 0\r\n      0 0 0 1\r\n      0 0 0 0\r\n      0 1 0 0 ];\r\nC = maximalcliques(A);\r\nC = fliplr(sortrows(C')');\r\nC_correct = [ 1 0 0\r\n              0 1 0\r\n              0 0 1\r\n              0 1 0 ];\r\nassert(isequal(C,C_correct))\r\n\r\n%%\r\nA = [ 0 1 0 0 0\r\n      1 0 1 1 0\r\n      0 1 0 1 0\r\n      0 1 1 0 1\r\n      0 0 0 1 0 ];\r\nC = maximalcliques(A);\r\nC = fliplr(sortrows(C')');\r\nC_correct = [ 1 0 0\r\n              1 1 0\r\n              0 1 0\r\n              0 1 1\r\n              0 0 1 ];\r\nassert(isequal(C,C_correct))\r\n\r\n%%\r\nA = [ 0 1 1 0 0 0\r\n      1 0 1 1 0 0\r\n      1 1 0 0 1 0\r\n      0 1 0 0 1 0\r\n      0 0 1 1 0 1\r\n      0 0 0 0 1 0 ];\r\nC = maximalcliques(A);\r\nC = fliplr(sortrows(C')');\r\nC_correct = [ 1 0 0 0 0\r\n              1 1 0 0 0\r\n              1 0 1 0 0\r\n              0 1 0 1 0\r\n              0 0 1 1 1\r\n              0 0 0 0 1 ];\r\nassert(isequal(C,C_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2014-10-28T22:05:02.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-10-28T21:53:54.000Z","updated_at":"2014-10-28T22:05:02.000Z","published_at":"2014-10-28T22:05:02.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/media/image1.png\"}],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis is a variant of a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2646-determine-the-number-of-maximal-cliques-in-an-undirected-graph\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eprevious problem\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e on maximal cliques. Instead of simply computing the number of maximal cliques in an undirected graph, now you must return the cliques themselves.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an NxN adjacency matrix (A) for an undirected graph with N vertices, return an array (C) in which each column encodes one of the maximal cliques in the graph. If C(i,j) = 1, then the ith vertex in the graph is included in the jth clique. The order of columns does not matter, but all maximal cliques must be given - that is, size(C,2) should equal the number of maximal cliques.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider the graph shown below,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"-1\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhich has the following adjacency matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[A = [ 0 1 0 0 0\\n      1 0 1 1 0\\n      0 1 0 1 0\\n      0 1 1 0 1\\n      0 0 0 1 0 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe maximal cliques are {1,2}, {2,3,4}, and {4,5}. Therefore, one (of three) valid outputs is:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[C = [ 1 0 0\\n      1 1 0\\n      0 1 0\\n      0 1 1\\n      0 0 1 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNOTE: You may assume the data type of the adjacency matrix (A) is double.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAADAFBMVEV4eHiTk5P29vaBgYGcnJzAwMC3t7eKiorS0tLt7e3b29vk5OTJycn///9vb28AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD61b95AAAAyklEQVR42q2SSQ6FIAxAWzQxkcj976lEE5R+hojQOmw+Cxa8RwcoGnhf6oNDD0AvGL8j/E2wC+JiXwSaAKbbatGkLjBrX13szynmtPXnKc2eCRiMGQtXxrq2hmZRuuXx6SVdPlPpopeC387sFMMIwdsyAMFAEcHuptW5oIaKYgjHBBoZ512snMeJ8g7o0DmA5jwKXRdqy9W6gfMzhd7iMOySlxq0qn/z4leR43HNQ8WrLtYi1Dz+pnjsmt/8ZsulwLgQOOeC4EyQHH5z1GUZiLNTtwAAAABJRU5ErkJggg==\"}]}"}],"term":"tag:\"adjacency matrix\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"adjacency matrix\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"adjacency matrix\"","","\"","adjacency matrix","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f73672028a8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f7367202808\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f73672010e8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f7367202b28\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f7367202a88\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f73672029e8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f7367202948\u003e":"tag:\"adjacency matrix\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f7367202948\u003e":"tag:\"adjacency matrix\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"adjacency matrix\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"adjacency matrix\"","","\"","adjacency matrix","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f73672028a8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f7367202808\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f73672010e8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f7367202b28\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f7367202a88\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f73672029e8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f7367202948\u003e":"tag:\"adjacency matrix\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f7367202948\u003e":"tag:\"adjacency matrix\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2730,"difficulty_rating":"easy-medium"},{"id":2646,"difficulty_rating":"unrated"},{"id":2647,"difficulty_rating":"unrated"}]}}