The problem states that we want to show that Independent Set poly-time reduces to Relative Prime Sets, more formally Independent Set <p Relative Prime Sets.
I need to provide a reduction f from ind.set to rel. prime sets, where
- input of f must be a Graph G and an integer k, where k denotes the size of an independent set.
- output of f must be a set S of integers and an integer t, where t denotes the number of pairwise relative prime numbers in the set S.
Definition of relative prime sets (decision version):
it takes a set P of n-integers and an integer t from 1 to n.
returns yes if there's a subset A of P, with t-many pairwise relative
primes. That is, for all a, b in A, it must be true that gcd(a, b) =
1.
returns no otherwise
So far I have come-up with what I believe is a reduction, but I am not sure if it is valid and I want to double check it with someone who knows how to do this.
Reduction:
Let G be a graph.Let k indicate the size of an independent set. Then we
want to find-out if there exists an independent set of size k in G.
Since this problem is NP-Complete, if we can solve another NP-Complete
problem in poly-time, we know that we can also solve Independent Set
in poly-time. So we chose to reduce independent set to Relative Prime
Sets.
We take the graph G and label its vertices from 1 to n as pr the
definition of the input for relative prime sets. Then we find the gcd
of each node to every other node in G. We draw an edge between the
nodes that have gcd(a, b) = 1. When the graph is complete, we look at
the nodes and determine which nodes are not connected to each other
via an edge. We create sets for those nodes. We return the set
containing the most nodes along with an integer t denoting the number
of integers in the set. This is the set of the most relative prime
numbers in the graph G and also the greatest independent set of G.
Suppose two graphs, each of four nodes. On graph one, the nodes are connected in a line so that the max-independent set is 2. Graph two is a complete graph each node is connected to each other node, so the max-independent set is 1.
It sounds like your reduction would result in the same set for each graph, leading to an incorrect result for independent set.
equation,S=k*lnW discrete logaritm can`t be broken because is corelated with informational entropy
Related
Let's say i have a directed graph G(V,E) with edge cost(real number) ∈ (0,1).For given i,I need to find all the couples of vertices (i,j) starting from i that "match".Two vertices (i,j) match if there is a directed path from i to j with length exactly k(k is a given number that is relatively small and could be considered as constant)with cost >=C(C is a given number).Cost of a path is calculated as the product of it's edges.For example if a path starting from i and ending in j of lenght 2 consists edges e1 and e2 then CostOfpath=cost(e1)*cost(e2).
This has to be done in O(E+V*k).So what i thought is modifying the DFS algorithm updating the distances from given starting vertice i until they reach the length of k.If they don't then we can't have a match.However i am having a hard time finding what exactly i can modify in the DFS.Any ideas?
When you need to consider paths with a fixed number of edges in it, dynamic programming often comes to help (while other approaches often fail).
Let's denote dp[v][j] the maximal cost of the path from vertex i (fixed) to vertex v that has exactly j edges.
For a starting values, you can set values for j==1: dp[v][1] is the cost of edge from i to v (or 0 if no such edge exists). Or if you think on it it will be obvious that you can set values for j==0, not j==1: dp[i][0] is 1, while dp[v][0] can be set to zero for v!=i.
Now, if you have values for some j, it is easy to calculate values for j+1:
dp[v][j+1] = max( dp[v'][j] * cost((v', v)) )
This is very similar to Ford-Bellman's algorithm, only that the latter does not need to track the number of edges and thus can use one-dimensional array.
This gives you the solution in O((E+V)*k). Not exactly what you have requested, but I doubt that there exists solution in O(E+V*k).
(In the solution above, I assume that the constant C is positive, and so a zero cost path is equivalent to the path being absolutely absent. If you need, you can specifically account for the C==0 case.)
Am trying to solve a question at this link:
https://www.chegg.com/homework-help/questions-and-answers/consider-weighted-directed-graph-g-n-vertices-e-edges-weights-integers-suppose-g-contains--q12054851
(this is not a homework question)
Consider a weighted directed graph G with n vertices and e edges, and the weights are integers. Suppose that G contains no negative cycles, and for every pair of vertices u and v in G, the distance from u to v falls in the range [-2d, 2d] for some positive integer d. We are going to fix a particular edge (x,y) in G, and consider what happens to the distances in G as we change the weight associated with that edge (and leave all other edge weights fixed).
Design an algorithm that takes G as input, as well as a specified edge (x,y) in G. The output of the algorithm should be an integral range of values that the weight of this edge (x,y) could take such that all of the distances in G would remain the same. Note that this range will be non-empty, as it must include the original weight of the edge (x,y). Also note that infinity may occur as an endpoint of your range (i.e. the range may not be finite). For this, you may return “∞” as an endpoint. The running time of your algorithm must be polynomial in n,e, and d (so your running time should not have any of these parameters appearing as exponents). Prove why the algorithm is correct.
I have been thinking on the following lines:
Since distances are in a range, weights should also be in a range. One option is we run Djkstra's multiple times. How do we optimize this?
Yes, you can run Dijkstra n times. Alternatively you can run Floyd-Warshall, which is designed for these problems. Overall, they have similar complexity bounds.
I have a bipartite graph G. I would like to find a fast algorithm (asymptotically) to find an assignment of all the vertices of G into two sets X and Y such that the complete bipartite graph formed by the sets X and Y has as many edges as possible.
Slightly longer explanation:
G is bipartite and consists of a set connected components (each of which are bipartite, obviously). We want to decide on a positioning (for lack of a better word) of each component into X and Y. After deciding upon all the positionings, we complete the bipartite graph (i.e. we connect every vertex of X to every vertex of Y). We then count out how many edges are there totally (including original edges) and we want to maximize this count. Simple math shows that the number of edges would be |X|*|Y|.
My thought process for a solution:
As the number of components increase, the number of choices for G increases exponentially. However, if we take number of connected components of G to be equal to number of nodes in G, then the solution is simple - split so that number of nodes in X and Y are equal (or almost equal in case of odd number of nodes in G). This makes me want to generalize that the problem is the same thing as trying to minimize the difference in cardinalities of X and Y (which can be solved as in this SO question). However, I have been unsuccessful in proving so.
Let's decompose the problem.
Your graph is actually a set of connected components, each connected
component is (U_i,V_i,E_i).
To maximize the number of edges, you need to maximize the value of
|X|*|Y|
To get the maximal value of |X|*|Y|, you obviously need to use all
vertices (otherwise, by adding another vertex, you get a bigger value).
Your freedom of choice is actually to choose for each component i - if you should add U_i to X, and V_i to Y - or vise versa.
So, what you are actually trying to do is:
maximize:
sum { x_i * |V_i| : for each component i} * sum { y_i * |U_i| : for each component i}
subject to constraints:
x_i, y_i in {0,1} for all i
x_i + y_i = 1 for all i
The value we want to maximize behaves similar to the function f(x) = x(k-x), because if we increase |X|, it comes at the expanse of decreasing |Y|, and by the same amount. This function has a single maximum:
f(x) = xk - x^2
f'(x) = k - 2x = 0 ---> x = k/2
Meaning, we should distribute the nodes such that the cardinality (size) of X and Y are closest as possible to each other (and use all the vertices).
This can be reduced to Partition Problem:
Given U_1,V_1,U_2,V_2,...,U_k,V_k
Create an instance of partition problem:
abs(|U_1| - |V_1|), abs(|U_2| - |V_2|), ... , abs(|U_k| - |V_k|)
Now, the optimal solution found to partition problem can be translated directly to which of U_i,V_i to include in which set, and will make sure the difference in sizes is kept to minimum.
I am trying to find the maximal set for an undirected graph and here is the algorithm that i am using to do so:
1) Select the node with minimum number of edges
2) Eliminate all it's neighbors
3) From the rest of the nodes, select the node with minimum number of edges
4) Repeat the steps until the whole graph is covered
Can someone tell me if this is right? If not, then why is this method wrong to calculate the maximal independent set in a graph?
What you have described will pick a maximal independent set. We can see this as follows:
This produces an independent set. By contradiction, suppose that it didn't. Then there would have to be two nodes connected by edges that were added into the set you produced. Take whichever one of them was picked first (call it u, let the other be v) Then when it was added to the set, you would have removed all of its neighboring nodes from the set, including node v. Then v wouldn't have been added to the set, giving a contradiction.
This produces a maximal independent set. By contradiction, suppose that it didn't. This means that there is some node v that can be added to the independent set produced by your algorithm, but was not added. Since this node wasn't added, it must have been removed from the graph by the algorithm. This means that it must have been adjacent to some node added to the set already. But this is impossible, because it would mean that the node v cannot be added to the produced independent set without making the result not an independent set. We have a contradiction.
Hope this helps!
There is not one definite maximal independent set in any graph; take for example the cycle over 3 nodes, each of the nodes forms a maximal independent set. Your algorithm will give you one of the maximal independent sets of the graph, without guaranteeing that it has maximum cardinality.On the other hand, finding the maximum independent set in a graph is NP-complete (since that problem is complementary to that of finding a maximum clique), so there probably isn't an efficient algorithm.
After your clarify situation in comments, your solutions is right.
Even better, according to Corollary 3 from this paper http://courses.engr.illinois.edu/cs598csc/sp2011/Lectures/lecture_7.pdf
your get good aproximation for subset order.
Greedy gives a 1 / (d + 1) -approximation for (unweighted) MIS in graphs of degree at most d
As you know finding maximum independent set is NP. Is there an algorithm to find out whether a given graph has an Independent set of at least k vertices? Note that we don't want to find it. We just want to find out if such thing exists.
Quoting Wikipedia:
In the independent set decision problem, the input is an undirected graph and a number k, and the output is a Boolean value: true if the graph contains an independent set of size k, and false otherwise.
This problem is NP-complete. Your problem asks the same question, just differently phrased, because a graph has an independent set of at least k vertices if and only if it has an independent set of exactly k vertices.
That means your problem is NP-complete too.
There is a nice lower bound on the size of maximum independent set ("graph independence number" denoted by alpha),
where d(v) is the degree of the vertex v and the sum is over all the vertices of a simple graph G. It was discovered independently by Wei and Caro (I found it in "Lower bounds on the independence number in terms of the degrees" by JR Griggs) and there are other lower bounds for different types of graphs.
What this means is that a maximum independent set will have at least k vertices with k given by this lower bound.