np

Reduction to Clique prob

眉间皱痕 提交于 2019-12-19 10:42:49
问题 Subgraph isomorphism We have the graphs G_1=(V_1,E_1), G_2=(V_2,E_2). Question : Is the graph G_1 isomorphic to a subgraph of G_2 ? (i.e. is there a subset of vertices of G_2, V ⊆ V_2 and subset of the edges of G_2, E ⊆ E_2 such that |V|=|V_1| and |E|=|E_1| and is there a one-to-one matching of the vertices of G_1 at the subset of vertices V of G_2, f:V_1 -> V such that {u,v} ∈ E_1 <=> { f(u),f(v) } ∈ E) Show that the problem Subgraph isomorphism belongs to NP. Show that the problem is NP

Reduction to Clique prob

爱⌒轻易说出口 提交于 2019-12-19 10:42:11
问题 Subgraph isomorphism We have the graphs G_1=(V_1,E_1), G_2=(V_2,E_2). Question : Is the graph G_1 isomorphic to a subgraph of G_2 ? (i.e. is there a subset of vertices of G_2, V ⊆ V_2 and subset of the edges of G_2, E ⊆ E_2 such that |V|=|V_1| and |E|=|E_1| and is there a one-to-one matching of the vertices of G_1 at the subset of vertices V of G_2, f:V_1 -> V such that {u,v} ∈ E_1 <=> { f(u),f(v) } ∈ E) Show that the problem Subgraph isomorphism belongs to NP. Show that the problem is NP

Algorithm to avoid obvious costly combinations when splitting n values to m groups

梦想与她 提交于 2019-12-13 05:13:01
问题 I have 7 values and I need to split them into 5 groups. Each group should contain atleast one value. There are 15 ways to group those values into 5. Mon- 13 Tue- 5 Wed- 4 Thu- 4 Fri- 11 Sat- 2 Sun- 1 When grouping, ordering of Mon, Tue, Wed, Thu, Fri, Sat, Sun should be preserved. Suppose there is a function which decides how good a grouping is. 13, 5, 4, 4, 11, 2, 1 Function Grouping 1 - 13, 5, [4,4], 11, [2,1] 13 added, 13 withdrawn, 0 remaining 5 added, 5 withdrawn, 0 remaining [4,4] added

Given an undirected graph G = (V, E), determine whether G is a complete graph

ε祈祈猫儿з 提交于 2019-12-12 06:16:06
问题 I'm pretty sure this problem is P and not NP, but I'm having difficulty coming up with a polynomially bound algorithm to solve it. 回答1: You can : check that number of edges in the graph is n(n-1)/2 . check that each vertice is connected to exaclty n-1 distinct vertices. This will run in O(V²) , which is polynomial. Hope it helped. 回答2: Here's an O(|E|) algorithm that also has a small constant. It's trivial to enumerate every edge in a complete graph. So all you need to do is scan your edge

Tile Trial NP-hard complexity

核能气质少年 提交于 2019-12-12 02:48:54
问题 In the game Final Fantasy XIII-3, the player is presented with a couple puzzles. The first puzzle introduced is called Tile Trial , which presents the player with a grid of tiles, some of which have crystals on them. The goal is to retrieve all of the crystals and reach the exit, while stepping on each tile no more than once. The author of http://arxiv.org/pdf/1203.1633v1.pdf stated that this problem is NP-Hard because a specific case can be reduced to Hamiltonian-cycle. I find that this is a

Array search NP complete [closed]

不羁岁月 提交于 2019-12-11 14:48:54
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Given an unsorted array of size n, it's obvious that finding whether an element exists in the array takes O(n) time. If we let m = log n then it takes O(2^m) time. Notice that if the array is sorted, a binary search actually takes O(m) time (which is polynomial) but the binary search cannot apply to an unsorted

How to optimize assignment of tasks to agents with these constraints?

强颜欢笑 提交于 2019-12-11 10:44:42
问题 I have an assignment problem as a part of my Master's Thesis, and I am looking for general direction in solving the same. So, there is a list of agents, and a list of tasks, with number of tasks being greater than the number of agents. The agents submit a prioritized ordered list of tasks they can/want to do. The length of the list is fixed to a number much smaller than the total number of tasks. Every agent must be assigned a task. A task once assigned cannot be assigned to another agent.

Bin Packing regarding Optimization and Decision Versions

和自甴很熟 提交于 2019-12-11 09:38:14
问题 I'm studying for an exam and we were given a set of practice problems. Here's one I'm struggling with and I hope somebody can help shed some light on the right approach to this problem: Here's my initial go at the problem: Decision Version: To find the optimal solution using the decision version, I would try using various K's until I got a yes answer. Let's say the optimized solution is 7, I would try : k=1, no k=2, no k=3, no k=4, no k=5, no k=6, no k=7, yes. So now that we know that the

np.where on multiple variables

拈花ヽ惹草 提交于 2019-12-11 07:40:06
问题 I have a data frame with: customer_id [1,2,3,4,5,6,7,8,9,10] feature1 [0,0,1,1,0,0,1,1,0,0] feature2 [1,0,1,0,1,0,1,0,1,0] feature3 [0,0,1,0,0,0,1,0,0,0] Using this I want to create a new variable (say new_var) to say when feature 1 is 1 then the new_var=1, if feature_2=1 then new_var=2, feature3=1 then new_var=3 else 4. I was trying np.where but though it doesn't give me an error, it doesn't do the right thing - so I guess a nested np.where works on a single variable only. In which case,

SQL query to find rows with the most matching keywords

你说的曾经没有我的故事 提交于 2019-12-11 02:01:21
问题 I'm really bad at SQL and I would like to know what SQL I can run to solve the problem below which I suspect to be a NP-Complete problem but I'm ok with the query taking a long time to run over large datasets as this will be done as a background task. A standard sql statement is preferred but if a stored procedure is required then so be it. The SQL is required to run on Postgres 9.3. Problem: Given a set of articles that contain a set of keywords, find the top n articles for each article that