{"id":22352759,"url":"https://github.com/alinpahontu2912/sat-problem-reduction","last_synced_at":"2025-06-30T06:33:50.861Z","repository":{"id":207572135,"uuid":"387456037","full_name":"alinpahontu2912/SAT-Problem-Reduction","owner":"alinpahontu2912","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-04T07:49:49.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T12:14:04.744Z","etag":null,"topics":["algorithm-challenges","satisfiability-solver"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alinpahontu2912.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-07-19T12:27:02.000Z","updated_at":"2021-08-04T07:49:52.000Z","dependencies_parsed_at":"2023-11-16T14:45:27.571Z","dependency_job_id":null,"html_url":"https://github.com/alinpahontu2912/SAT-Problem-Reduction","commit_stats":null,"previous_names":["alinpahontu2912/sat-problem-reduction"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alinpahontu2912/SAT-Problem-Reduction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FSAT-Problem-Reduction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FSAT-Problem-Reduction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FSAT-Problem-Reduction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FSAT-Problem-Reduction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alinpahontu2912","download_url":"https://codeload.github.com/alinpahontu2912/SAT-Problem-Reduction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alinpahontu2912%2FSAT-Problem-Reduction/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262724145,"owners_count":23354187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm-challenges","satisfiability-solver"],"created_at":"2024-12-04T12:27:05.848Z","updated_at":"2025-06-30T06:33:50.838Z","avatar_url":"https://github.com/alinpahontu2912.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Pahontu Stefan Alin 321CA --------------------------------------------------------------------------\n----------------------------------------------------------------------------------------------------\n------------------------------------Algorithm Analysis----------------------------------------------\nComplexity legend:\n'families' = the number of families ( =\u003e n )\n'spies' = the number of of spies ( =\u003e k )\n'lines' = the number of relations between families ( =\u003e m )\n'extended' = the size of the extended family ( =\u003e k )\n\nTask 1:\n    To find a spy for each family, I will consider from the very beginning that a family can only\nhave one unique spy. This means that I can translate this problem into just making sure that each\nfamily belongs to a spy and that a spy is not infiltrated into two families who get along. To solve\nthis problem, I will use a number of ('families' + 1) * 'spies' variables and a number of 'families'\nclauses. The first 'families' clauses contain 'families' * 'spies' variables that will tell me\nif each family has a spy, and to what spy it belongs. The last 'spies' clauses will check if the\nfamilies assigned to each spy are not connected.\n\nComplexities:\ninitializeHashmaps: O(n) + O(k), but since k is usually smaller than n, we can consider O(n)\nfindSpyless: O(1)\ncheckForSPy: O(1)\ngetAnswear: O(n * k)\ncheckSharedSpies: O(n1 * n1), where n1 is the number of families assigned to a spy;\n                worst case scenario: O(n^2), when the graph has no edges\nreadProblemData: O(m)\nformulateOracleQuestion: O(n * k)\ndecipherOracleAnswer: O(n * k),  worst-case is O(n^2)\nwriteAnswer: O(n * k) if answer is true O(1) otherwise\n\nTask 2:\n    We know that every graph with at least one edge, contains a clique of size 2. To solve this problem,\nI will check all the connections between the families (which I will be viewing as a non-oriented graph)\nto find the max-clique from the graph. If there are nodes that can make up a max-clique, if these nodes\nare indeed connected, meaning they form a clique and the size of the max-clique's size is greater than,\nor equal to the size of the clique we are searching for, it means the problem's answer is true. I will be\nusing 'nodes' + 2 variables and 3 clauses, the first containing 'nodes' variables and the second and third\nonly one. I will be checking if the size of the max-clique found is at least equal to the size I am\nsearching for and that the nodes I picked to make the max-clique are indeed connected. If the max-clique's\nsize is greater than the one I need, any combination of nodes making up the max-clique(of size equal to\nthe size of the clique I am searching for), will deliver a correct output. The first clause will contain\nthe first 'nodes' variables that will tell whether a node belongs to the max-clique and the second and third\nwill check if the chosen set of nodes is actually a clique and that its size is at least equal to the one\nI want.\nComplexities:\ninitializeHashmaps: O(n)\ngetCommon: O(n1 * n2), where n1 is the neighbours number of the first node\n                        and n2 is the neighbours number of the second node\n-\u003e worst case scenario is when both nodes are connected to every single node of the graph, resulting in O(n^2)\ncheckSize: O(1)\nfindCLique: O(n * (n - 1) * O(getCommon)) ( O(n^4) is the worst case scenario, when the graph is a complete\n                                            graph)\ncheckClique: O(n1^2), where n1 is the number of nodes from the subset considered a clique;\n                           worst case scenario: O(n^2), when the subset contains all the nodes from the graph\nreadProblemData: O(m)\nformulateOracleQuestion: O(n)\ndecipherOracleAnswer: O(n^2) (worst case scenario)\nwriteAnswer: O(k) if answer is true, O(1) if answer is false\n\nTask 3:\n    To find the minimum number of arrests, I have to remove the edges of a minimum number of nodes from\nthe graph, so that the remaining graph will have no edges. By reducing this problem to the precedent one,\nI have deducted that this is efficiently done by eliminating the edges outsides of the nodes that make up the\nmax-clique in the complementary graph. To do so, I will have to build the complementary graph and run task2\nuntil I get the size of the max-clique and the correct output will be nodes that are not part of it.\nNote: I will start by searching for cliques of size 'families', then decrease the size.\n\nComplexities:\ninitializeHashmaps: O(n)\nmakeComplementary: O(n^2)\nrelationsNumber: O(n)\nreadProblemData: O(m)\nreduceToTask2: O(n^2)\nextractAnswerFromTask2: O(l), where l is the size of the max-clique found in the complementary graph\nwriteAnswer: O(n)\n\nBonusTask:\n    To solve this task, I am using the same logic from the previous task. However, I will find the max-clique\nwithout having to reduce the problem to task2. This means I will have to check if the found clique covers every\nsingle edge in the graph, and it is of minimum size. To ensure it is a minimum clique, I will find the max-clique\nin the complementary graph, and then remove those nodes, so that the remaining ones are the ones I need. I gave\nevery soft clause a weight equal to 1, each representing whether the given node is part of the clique or not.\nTo make sure every edge is covered by the chosen clique and to improve performance, I am using the following logic:\nThe nodes in the clique I need contain all the edges of the graph. This means, I can rebuild the initial graph,\nby only using these nodes. To further improve performance, I am not building and comparing a new graph to the\noriginal one every time, I am only checking if the nodes in the clique I found have connections to all the nodes\nfrom the original.(If some nodes from the graph have no edges at all, I will also take them into consideration,\nwhile checking the 'new graph')\n\nComplexities:\ninitializeHashmaps: O(n)\nbelongsClique: O(1)\nfindNodes: O(l), where l is the size of the found clique\nmakeComplementary: O(n^2)\ngetCommon: O(n1 * n2), where n1 is the neighbours number of the first node\n                        and n2 is the neighbours number of the second node\n-\u003e worst case scenario is when both nodes are connected to every single node from the graph, resulting in O(n^2)\nfindCLique: O(n * (n - 1) * O(getCommon)) ( O(n^4) is the worst case scenario, when the graph is a complete\n                                            graph)\nreadProblemData: O(m)\nformulateOracleQuestion: O(n)\ndecipherOracleQuestion: O(n^2)\nwriteAnswer: O(n)\n\nNote: the complexity of the solve method will always be equal to the greatest complexity that appears in a function\nthat is used to solve a certain task, exception being task3, where the complexity will also depend on the number of\ntimes it takes to find out the max-clique by using task2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falinpahontu2912%2Fsat-problem-reduction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falinpahontu2912%2Fsat-problem-reduction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falinpahontu2912%2Fsat-problem-reduction/lists"}