Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "819640f9-7344-4ce9-9fc4-4fb3b0db2a35",
"metadata": {
"tags": []
},
"source": [
"# Assignment 4\n",
"### Zihao Liu\n",
"### 001567668"
]
},
{
"cell_type": "markdown",
"id": "274a8e1f-c901-4014-9225-6f2c07ecb486",
"metadata": {},
"source": [
"## Q1: k-edge-disjoint cycle-cover problem\n",
"**Problem Statement:**\n",
"\n",
"Given a directed graph $ G = (V, E) $, a k-edge-disjoint cycle-cover is a set of edge-disjoint cycles such that each edge $ e \\in E $ belongs to exactly one cycle. In other words, a k-edge-disjoint cycle cover of a graph$ G $ is a set of cycles which are sub-graphs of $G$ and contain all edges of $G$ exactly once. If the cycles of the cover have no edges in common, the cover is called an edge-disjoint cycle cover.\n",
"\n",
"The edge-disjoint cycle-cover problem asks whether a given directed graph has an edge-disjoint cycle cover.\n",
"\n",
"**Problem A (10 points): Is the edge-disjoint cycle-cover problem in P? If so, prove it.**\n",
"\n",
"*Answer:*\n",
"\n",
"This question is a known NP-Hard problem, meaning that there is no known polynomial-time solution for it unless P = NP. However, there are approximate polynomial-time algorithms to solve the problem.\n",
"\n",
"Naive Approach: Consider all subsets of edges and determine if they form a cycle that covers all vertices in the graph. For a graph with a small number of edges, this is feasible. For example, in a graph with only 4 edges, consider subsets like $\\{e_1, e_2\\}, \\{e_2, e_3\\}, \\{e_1, e_2, e_3, e_4\\}$, etc. Check if these subsets form cycles that cover all vertices in the graph. Update the optimal answer accordingly, and determine the subset with the minimum number of edges that covers all vertices of the graph.\n",
"\n",
"**Problem B (5 points): Suppose we require each cycle to have at most four edges. We call this the 4-edge-cycle-cover problem. Is the 4-edge-cycle-cover problem in NP? If so, prove it.**\n",
"\n",
"*Answer:*\n",
"\n",
"The 4-Edge-Cycle Cover Problem is similar to the Edge-Cycle Cover Problem but with an additional constraint that each cycle must have a length of at most four edges. \n",
"\n",
"4-Edge-Cycle Cover is in NP: The certificate of a \"yes\" instance is the cover itself. To check if it is a valid cover, inspect each cycle to ensure it is indeed a cycle and verify that each edge is covered. This process can be done in polynomial time.\n",
"\n",
"**Problem C (10 points): Is the 4-edge-cycle-cover problem NP-complete? If so, prove it.**\n",
"\n",
"*Answer:*\n",
"\n",
"To demonstrate that the 4-Edge-Cycle Cover is NP-hard, we can reduce from a known NP-hard problem such as the Hamiltonian Cycle problem. The reduction process involves constructing a graph in such a way that a solution to the 4-Edge-Cycle Cover problem on this graph would imply a solution to the Hamiltonian Cycle problem in the original graph. \n",
"\n",
"The construction and correctness proof would be intricate but based on ensuring that each Hamiltonian cycle in the original graph corresponds to a valid 4-edge-cycle cover in the constructed graph, and vice versa. The reduction can be performed in polynomial time, thus proving the NP-hardness of the 4-Edge-Cycle Cover problem. \n",
"\n",
"Given the problem is in NP and NP-hard, it is NP-complete."
]
},
{
"cell_type": "markdown",
"id": "bafbc806-442f-4a0b-8a90-cfbbb2f0cddf",
"metadata": {},
"source": [
"## Q2: The Directed Edge-Disjoint Paths Problem\n",
"\n",
"#### Context\n",
"In graph theory, the Directed Edge-Disjoint Paths Problem involves finding paths in a directed graph such that no two paths share an edge. This problem is fundamental in network routing where paths represent communication links.\n",
"\n",
"#### Problem Statement\n",
"\n",
"Given a directed graph $ G = (V, E) $ and $ k $ pairs of nodes $ (s_1, t_1), (s_2, t_2), \\ldots, (s_k, t_k) $, the Directed Edge-Disjoint Paths Problem asks whether there exist $ k $ edge-disjoint paths $ P_1, P_2, \\ldots, P_k $ such that each path $ P_i $ connects $ s_i $ to $ t_i $ without sharing any edges with other paths. Is the Directed Edge-Disjoint Paths Problem NP-complete?\n",
"\n",
"**Answer:**\n",
"Consider the k Edge-Disjoint Shortest Paths Problem, where we are given a graph and pairs of vertices $ (s_1, t_1), \\ldots, (s_k, t_k) $. The goal is to find $k$ pairwise edge-disjoint paths $ P_1, \\ldots, P_k $ such that each path $P_i$ is a shortest path from $ s_i $to $ t_i $, if such paths exist. When the length of each edge is zero, this simplifies to the edge-disjoint paths problem.\n",
"\n",
"If we consider positive edge lengths, certain variants of the problem can be solved in polynomial time. However, the 2 Edge-Disjoint Paths Problem in directed graphs is known to be NP-hard (referencing Richard M. Karp's work on computational complexity). Therefore, the Directed Edge-Disjoint Paths Problem, even for $ k = 2 $, is NP-hard. This conclusion applies to almost all variants of the directed $k $ Edge-Disjoint Shortest Paths Problem, with only a few exceptions known to be solvable in polynomial time."
]
},
{
"cell_type": "markdown",
"id": "19260f89-e40c-4c66-aa3b-7118df46a5f0",
"metadata": {},
"source": [
"## Q3: Efficient Project Team Formation\n",
"\n",
"You are leading a project that requires a diverse set of skills (e.g., software development, project management, graphic design, data analysis, marketing, etc.). You have received applications from $ m $ potential team members. Each individual possesses a subset of the necessary skills. The challenge is: For a given number $ k \\leq m $, is it possible to assemble a project team of at most $ k $ members that collectively possess all required skills? This problem will be called the Efficient Project Team Formation.\n",
"\n",
"**Answer:**\n",
"\n",
"1. **The problem is in NP**: Given a set of $ k $ team members, we can efficiently check in linear time relative to the number of skills and $ k $ members, whether every required skill is covered by at least one team member.\n",
"\n",
"2. **Proving NP-completeness**: This problem can be shown to be NP-complete by reducing from the Set Cover problem. In the Set Cover problem, given a set $ U $ of $ n $ elements, and a collection of $ m $ subsets of $ U $ whose union equals the set of elements, the question is whether there are at most $ k $ of these subsets whose union covers all of $ U $. Given an instance of Set Cover, we can construct an instance of Efficient Project Team Formation as follows: For each element of $ U $, create a required skill. For each of the $ m $ subsets in Set Cover, create a potential team member with skills corresponding to the elements in that subset. This reduction is done in polynomial time.\n",
"\n",
"3. **Conclusion**: There exists a team of $ k $ members that collectively possess all required skills if and only if there are $ k $ subsets in the Set Cover problem whose union covers all elements of $ U $. Thus, Set Cover ≤P Efficient Project Team Formation. Therefore, Efficient Project Team Formation is an NP-Complete problem."
]
},
{
"cell_type": "markdown",
"id": "6cc29573-c4ef-4334-ab66-11d40a8a5efb",
"metadata": {},
"source": [
"## Q4: Efficient Event Staffing Problem\n",
"Consider you're coordinating a large-scale international conference that features multiple thematic sessions, such as technology, economics, culture, etc. The conference requires at least one expert for each thematic session. There have been applications from a number of potential speakers. For each thematic session, there is a subset of these applicants who are qualified to speak on that topic. The question is: For a given number $ k < m $ (where $ m $ is the number of applicants), is it possible to select at most $ k $ speakers and ensure at least one qualified speaker for each thematic session? This is known as the Efficient Event Staffing Problem.\n",
"\n",
"**Answer:**\n",
"\n",
"1. **The Problem is in NP:** Given a set of $ k $ speakers, we can easily verify in linear time relative to the number of thematic sessions and $ k $ speakers, whether each session has at least one speaker who is qualified to present on its topic.\n",
"\n",
"2. **Proving NP-Completeness through Reduction from Set Cover:**\n",
" - **Recall the Set Cover Problem:** Given a set $ U $ of $ n $ elements and a collection of $ m $ subsets of $ U $ whose union equals the set of elements, the question is whether there exist at most $ k $ of these subsets whose union equals all of $ U $.\n",
" - **Reduction to Efficient Event Staffing:** For each element of $ U $, create a thematic session. For each of the $ m $ subsets, create a speaker and assign expertise to this speaker in the sessions corresponding to the elements of this subset. This reduction is clearly polynomial in time.\n",
" - **Equivalence of Solutions:** If there are $ k $ speakers who collectively cover all thematic sessions, this corresponds to $ k $ subsets whose union is $ U $ in the Set Cover problem. Thus, Set Cover ≤P Efficient Event Staffing.\n",
"\n",
"3. **Conclusion:** Since we have shown that the Efficient Event Staffing Problem is in NP and that Set Cover (a known NP-Complete problem) can be polynomially reduced to it, we conclude that the Efficient Event Staffing Problem is NP-Complete."
]
},
{
"cell_type": "markdown",
"id": "5e645a2c-f307-4ab3-88a4-308c0a901225",
"metadata": {},
"source": [
"## Q5 \n",
"Imagine you are part of a community group, the \"Garden and Stars Collective,\" that consists of m members. Over the next m days, each member is expected to lead a community activity once, ensuring that there's a leader for each day.\n",
"\n",
"However, everyone has commitments on certain days (like yoga classes, space lectures, etc.), making the scheduling of leaders a challenging task. To structure this, let's denote the members as M ∈ {m1, ..., mm} and the days as D ∈ {d1, ..., dm}. For member mi, there is a set of days Ti ⊂ {d1, ..., dm} when they are unavailable to lead. No member can have Ti empty.\n",
"\n",
"If a member fails to lead on any of the m days, they must contribute $100 to the community fund. \n",
"\n",
"A) Frame this problem as a maximum flow problem to maximize the number of matches between the members and the days.\n",
"\n",
"**Algorithm:**\n",
"\n",
"1. Construct a graph with a source vertex s and a sink vertex t.\n",
"2. For each member mi, create a vertex xi, representing the member's availability to lead. Add an edge from the source s to xi with a capacity of 1.\n",
"3. For each day dj, create a vertex yj, indicating the need for a leader on that day. Add an edge from yj to the sink t with a capacity of 1.\n",
"4. For each member mi, let Ai be the set of days they are available to lead (the complement of Ti). For each a ∈ Ai, add an edge from xi to ya with infinite capacity.\n",
"5. Run the Ford-Fulkerson algorithm on this graph to compute the flow and then determine the minimum cut.\n",
"6. For edges (s, xi) in the cut, check with the member mi. For edges (yj, t) in the cut, assign member mi to lead on day dj.\n",
"\n",
"B) Is it always possible to match all m members with one of the m days? Justify your answer.\n",
"\n",
"**Answer:**\n",
"\n",
"The feasibility of matching all members to a day depends on the availability patterns. For instance, if all members are unavailable on a specific day, say Tuesday, it's impossible to find a leader for that day. The best solution might be to contribute $100 to the community fund for Tuesday and schedule members for other days, assuming there is at least one available member per day. \n",
"\n",
"Moreover, if the schedule requires more than 'm' days, it's unfeasible to have a leader for each of the 'm' days. Conversely, if the schedule requires at most 'm' days, then arranging a leader for each day is possible."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ba71135a-ea73-491a-8e5b-f3e30f632f5f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added Submissions/001567668_Zihao_Liu/A4Q5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 0 additions & 19 deletions Submissions/001567668_Zihao_Liu/Assignment2_Readme.md

This file was deleted.

19 changes: 0 additions & 19 deletions Submissions/001567668_Zihao_Liu/Assignment3_Readme.md

This file was deleted.

Loading