Question 1
Determine if true or false:
- :
- :
- :
- :
- :
- :
- :
Question 2
- COLOURING problem
Input of graph and set of colours and returns if every vertex can be assigned a colour from such that no two adjacent vertices share the same colour.
- We have colours, for vertices. ()
- We have to check all edges, which takes .
- VERTEX-COVER problem Given a graph and integer , it returns if there exists a subset of size such that every edge in is adjacent to some vertex . There are vertices, we have to select vertices, To check everything, would require .
- GRAPH-ISO problem We get two graphs and and returns if is Isomorphic to . The simplest way to check isomorphism is to use brute force to generate and check mappings.
- SUBGRAPH-ISO problem
Question 3
- is only satisfiable there is a clique of size .
graph {
layout=circo
subgraph cluster0 {
P, nQ, nS
}
subgraph cluster1 {
Q, nR
}
subgraph cluster2 {
R, S
}
P--Q,nR,R,S
nQ--nR,R,S
nS--Q,nR,R
Q--R,S
nR--S
}There are two cliques: , and .
- is only satifiable there is a clique of size
graph {
layout=circo
subgraph cluster0 {
nP, Q, R
}
subgraph cluster1 {
P, nQ
}
subgraph cluster2 {
nQ1, R1
}
nP--nQ,nQ1,R1
Q--P,R1
R--P,R1
P--nQ1,R1
nQ--nQ1,R1
}Question 4
Given , construct a graph such that is satisfiable contains a Hamiltonian cycle.
digraph {
rankdir=LR
node [label="" shape=circle]
clause1, clause2, clause3 [shape=rectangle]
clause1 [label="-P or R"]
clause2 [label="Q or R"]
clause3 [label="P or -Q"]
# P
subgraph clusterGadget0 {
label="P"
true0 [color=green]
false0 [color=red]
init0 [color=aqua]
init0 -> true0, false0
true0, false0 -> exit0
# clause 1
false0->mid0_0
mid0_0->false0
mid0_0->clause1
mid0_0->mid0_1
mid0_1->mid0_0
clause1->mid0_1
mid0_1->mid0_2
# clause 3
true0->mid0_3
mid0_3->true0
mid0_3->clause3
mid0_3->mid0_2
mid0_2->mid0_3
clause3->mid0_2
mid0_2->mid0_1
}
# Q
subgraph clusterGadget1 {
label="Q"
true1 [color=green]
false1 [color=red]
init1 -> true1, false1
true1, false1 -> exit1
# clause 2
true1->mid1_0
mid1_0->true1
mid1_0->clause2
clause2->mid1_1
mid1_0->mid1_1
mid1_1->mid1_0
mid1_1->mid1_2
# clause 3
false1->mid1_3
mid1_3->false1
mid1_3->clause3
clause3->mid1_2
mid1_2->mid1_3
mid1_3->mid1_2
mid1_2->mid1_1
}
# R
subgraph clusterGadget2 {
label="R"
true2 [color=green]
false2 [color=red]
init2 -> true2, false2
true2, false2 -> exit2
# clause 1 (true)
true2->mid2_0
mid2_0->true2
mid2_0->clause1
clause1->mid2_1
mid2_0->mid2_1
mid2_1->mid2_0
mid2_1->mid2_2
# clause 2 (true)
mid2_2->mid2_1
mid2_2->clause2
clause2->mid2_2
mid2_2->mid2_3
mid2_3->mid2_2
mid2_3->false2
false2->mid2_3
}
# link all gadgets
exit0->init1
exit1->init2
exit2->init0
}Question 5
Show SUBGRAPH-ISO is NP-hard by constructing the polynomial reductions.
SUBGRAPH-ISO takes in two graphs and returns true if is an isomorphic to a sub-graph of .
- CLIQUE SUBGRAPH-ISO //
- HAMILTONIAN SUBGRAPH-ISO