comp362–%assignment%4%3%solutions% question1:)cgm.cs.mcgill.ca/~breed/2015comp362/ex4-sol.pdf ·...

3
COMP 362 – Assignment 4 Solutions Question 1: Firstly we show that Partial Isomorphism (PI) is in NP. This is true because given a function from the vertices of to the vertices of some subgraph ! of we can in linear time decide if this is an isomorphism. Secondly we show a reduction from the CLIQUE problem to PI problem. Given an input of a graph and some integer for the CLIQUE problem we translate it to an input of the PI problem by taking to be ! , i.e. a clique on vertices, and the graph to be the same graph. PI answer yes on its input if and only if contains a clique of size . Question 2: Let be a graph with maximum degree 2 and left = . We call the sequence !,! , !,! , , !,! , !,! , , !,! , !!!,! defined in class an adjacency sequence. We start by finding lexicographically maximal adjacency sequence for each of the connected components in . Let be such a component. For each vertex we generate a list of adjacency sequences with ! = that contains the lexicographically maximal such sequence. We claim that we generate at most 1 ! ! such sequences corresponding to each . Thus the running time to find ! () is at most 1 ! ! = ! ! . Therefore the total time taken over all the components is ! . The next step would be to sort the adjacency sequences that we got for each connected component. The vertices of the first adjacency sequence would keep their labels, the vertices of the second will shift by the number of vertices in the component which corresponds to the first adjacency sequence and etc. The running time of the second step is as at most ! . Indeed, we need to sort only the adjacency sequences that correspond to components of size at least two. The adjacency sequences that correspond to connected components of size one will be last in the sort. Every adjacency sequence is of size at most ! and there are at most ! ! adjacency sequences which correspond to components of size at least two. We can sort by considering the sequences starting from the least significant bit to the most, and sort in each step only with respect to this bit (as in radix sort). To perform the sorting it is enough to scan all the sequences a constant time, therefore the running time is at most ! ! ! which is again ! . It remains to prove the claim. We actually generate, for every , a list ! of sequences of vertices beginning with such that ! () extends one of those sequences. For () 1 and any sequence in ! , since is connected, there

Upload: others

Post on 08-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COMP362–%Assignment%4%3%Solutions% Question1:)cgm.cs.mcgill.ca/~breed/2015COMP362/Ex4-sol.pdf · Foreveryvertex)!∈!)weassociateavectoroflength) !)suchthat)theiRth) coordinate)in)the)vector)is)the)number)of)neighbours)of)!)ofdegree!

COMP  362  –  Assignment  4  -­‐  Solutions  Question  1:    Firstly  we  show  that  Partial  Isomorphism  (PI)  is  in  NP.  This  is  true  because  given  a  function  𝑓  from  the  vertices  of  𝐻  to  the  vertices  of  some  subgraph  𝐺!  of  𝐺  we  can  in  linear  time  decide  if  this  is  an  isomorphism.    Secondly  we  show  a  reduction  from  the  CLIQUE  problem  to  PI  problem.  Given  an  input  of  a  graph  𝐺  and  some  integer  𝑘  for  the  CLIQUE  problem  we  translate  it  to  an  input  of  the  PI  problem  by  taking  𝐻  to  be  𝐾! ,  i.e.  a  clique  on  𝑘  vertices,  and  the  graph  𝐺  to  be  the  same  graph.    PI  answer  yes  on  its  input  if  and  only  if  𝐺  contains  a  clique  of  size  𝑘.    Question  2:  Let  𝐺  be  a  graph  with  maximum  degree  𝑑 ≥ 2  and  left   𝑉 𝐺 = 𝑛.  We  call  the  sequence   𝑥!,!, 𝑥!,!,… , 𝑥!,!, 𝑥!,!,… , 𝑥!,!, 𝑥!!!,!  defined  in  class  an  adjacency  sequence.    We  start  by  finding  lexicographically  maximal  adjacency  sequence  for  each  of  the  connected  components  in  𝐺.  Let  𝑈  be  such  a  component.  For  each  vertex  𝑣 ∈ 𝑉 𝑈  we  generate  a  list  of  adjacency  sequences  with  𝑥! = 𝑣  that  contains  the  lexicographically  maximal  such  sequence.  We  claim  that  we  generate  at  most  𝑑 − 1 ! !  such  sequences  corresponding  to  each  𝑣 ∈ 𝑉 𝑈 .  Thus  the  running  time  to  find  𝐶!(𝑈)  is  at  most  𝑂 𝑉 𝑈 𝑑 − 1 ! ! = 𝑂 𝑑 ! ! .  Therefore  the  total  time  taken  over  all  the  components  is  𝑂 𝑑! .    The  next  step  would  be  to  sort  the  adjacency  sequences  that  we  got  for  each  connected  component.  The  vertices  of  the  first  adjacency  sequence  would  keep  their  labels,  the  vertices  of  the  second  will  shift  by  the  number  of  vertices  in  the  component  which  corresponds  to  the  first  adjacency  sequence  and  etc.    The  running  time  of  the  second  step  is  as  at  most  𝑂 𝑑! .  Indeed,  we  need  to  sort  only  the  adjacency  sequences  that  correspond  to  components  of  size  at  least  two.  The  adjacency  sequences  that  correspond  to  connected  components  of  size  one  will  be  last  in  the  sort.  Every  adjacency  sequence  is  of  size  at  most  𝑛!  and  there  are  at  most  !

!  adjacency  sequences  which  correspond  to  components  of  size  at  least  two.  

We  can  sort  by  considering  the  sequences  starting  from  the  least  significant  bit  to  the  most,  and  sort  in  each  step  only  with  respect  to  this  bit  (as  in  radix  sort).  To  perform  the  sorting  it  is  enough  to  scan  all  the  sequences  a  constant  time,  therefore  

the  running  time  is  at  most  𝑂 !!

!  which  is  again  𝑂 𝑑! .  

It  remains  to  prove  the  claim.  We  actually  generate,  for  every  𝑖 ≤ 𝑉 𝑈 ,  a  list  ℒ!  of  sequences  of  𝑖  vertices  beginning  with  𝑣  such  that  𝐶!(𝑈)  extends  one  of  those  sequences.  For  𝑖 ≤ 𝑉(𝑈) − 1  and  any  sequence  𝑆  in  ℒ! ,  since  𝑈  is  connected,  there  

Page 2: COMP362–%Assignment%4%3%Solutions% Question1:)cgm.cs.mcgill.ca/~breed/2015COMP362/Ex4-sol.pdf · Foreveryvertex)!∈!)weassociateavectoroflength) !)suchthat)theiRth) coordinate)in)the)vector)is)the)number)of)neighbours)of)!)ofdegree!

is  an  edge  from  a  vertex  in  𝑆  to  a  vertex  of  𝑈  not  in  𝑆.  Let  𝑥!  be  the  first  vertex  in  the  sequence  that  sees  a  vertex  not  in  𝑆.  Clearly,  if  𝐶! 𝑈  extends  𝑆  then  the  first  vertex  after  𝑆  in  𝐶! 𝑈  must  be  a  neighbour  of  𝑥!.  There  are   𝑑 − 1  choices  for  this  neighbour.  This  creates   𝑑 − 1  extensions  of  𝑆  that  we  add  to  ℒ!!!.  The  sequence  𝐶! 𝑈  must  extend  one  of  these  extensions  of  𝑆  for  some  𝑆 ∈ ℒ! .  This  proves  the  claim.    Question  3:  (i)  Let  𝐺!,𝐺!  be  two  graphs  as  in  the  question.  As  shown  in  class,  for  any  3-­‐connected  planar  graphs,  for  any  two  edges   𝑥,𝑦  and   𝑣,𝑢  in  𝐺!  and  𝐺!  respectively,  there  are  at  most  two  isomorphisms  𝑓  from  𝐺!  to  𝐺!  with    𝑓 𝑥 = 𝑢  and  𝑓 𝑦 = 𝑣.  This  is  since  there  are  two  clockwise  orientation  scheme  corresponding  to  the  unique  embedding  of  𝐺!.  Thus  there  exist  at  most  four  isomorphisms  𝑓  where   𝑓 𝑥 , 𝑓 𝑦 = 𝑣,𝑢  and  so  at  most  4|𝐸 𝐺! |  isomorphisms  from  𝐺!  to  𝐺!  in  total.      (ii)  We  first  prove  by  induction  that  for  any  two  rooted  trees  𝑇!,𝑇!,  the  number  of  isomorphisms  between  them  is  at  most  the  product  of  the  (number  of  children)!  (factorial).    Indeed  for  any  rooted  trees  𝑇!,𝑇!  with  roots  𝑟!, 𝑟!,  respectively,  any  rooted  isomorphism  form  𝑇!  to  𝑇!  consists  of  some  matching  between  the  children  of  𝑟!  and  the  children  of  𝑟!,  and,  for  each  matching  edge  joining  a  child  𝑐!  or  𝑟!  to  a  child  𝑐!  of  𝑟!,  of  a  rooted  isomorphism  between  the  subtree  formed  by  𝑐!  and  its  descendants  and  the  subtree  formed  by  𝑐!  and  its  descendants.  The  number  of  isomorphisms  from  𝑇!  to  𝑇!  is  the  sum  over  all  such  matchings  of  the  product  of  the  number  of  isomorphisms  between  rooted  subtrees  whose  roots  are  joined  by  the  matching.    For  two  rooted  trees  𝑇!,𝑇!  with  maximum  degree  3,  this  product  is  at  most  6 ⋅ 2!!!,  and  this  is  because  each  vertex,  but  the  root,  has  at  most  2  children.    To  decide  on  the  root,  we  use  the  fact  shown  in  class,  that  in  each  tree  there  is  either  a  unique  vertex  or  an  edge  that  separate  the  tree  into  two  components  each  of  size  

at  most   ! !!.  In  any  isomorphism  between  two  trees  their  corresponding  separating  

vertex  or  edge  must  be  mapped  to  each  other.  We  have  one  way  to  map  a  vertex  to  a  vertex  and  two  ways  to  map  an  edge  to  an  edge.  Once  we  fixed  this  mapping  we  can  consider  the  separating  vertex,  or  one  ends  of  the  separating  edge  as  roots  of  the  trees.      Question  4:  We  first  sort  all  the  vertices  by  their  degree.  Let  𝑉!  be  the  set  of  vertices  of  degree  𝑑.  This  sort  can  be  done  using  counting  sort  in  𝑂 𝑉 + 𝑉 = 𝑂 𝑉  time.    

Page 3: COMP362–%Assignment%4%3%Solutions% Question1:)cgm.cs.mcgill.ca/~breed/2015COMP362/Ex4-sol.pdf · Foreveryvertex)!∈!)weassociateavectoroflength) !)suchthat)theiRth) coordinate)in)the)vector)is)the)number)of)neighbours)of)!)ofdegree!

For  every  vertex  𝑣 ∈ 𝑉  we  associate  a  vector  of  length   𝑉  such  that  the  i-­‐th  

coordinate  in  the  vector  is  the  number  of  neighbours  of  𝑣  of  degree   !!− 𝑉 + 𝑖.  By  

condition  (ii)  of  the  question,  each  vertex  has  a  unique  vector  associated  with  it.    For  each  𝑉!  we  sort  the  vectors  corresponding  to  the  vertices  in  the  set  by  considering  them  from  the  right  most  coordinate  and  sorting  using  counting  sort  each  of  coordinates  (similar  to  radix  sort).  The  running  time  for  all  the  sets  is  at  most  𝑂 𝑉 ⋅ 𝑉 .    This  is  a  canonical  labeling.  The  running  time  is  at  most  𝑂 𝑉 + 𝐸 ,  because  we  have  that   𝐸 = 𝛩 𝑉 !  in  the  given  graph.