Given an undirected graph G and a subset of its vertices S, the subgraph of G induced by S (denoted G/S) is defined as the subgraph of the graph G such that the following two conditions are satisfied:
In this problem, you are given a tree G containing n vertices and a positive integer k. Initially, the vertices of G are numbered from 0 to n-1, inclusive. The objective is to change this numbering so that all induced subgraphs over {i, i+1, .., i+k-1} are connected, for all 0 <= i <= n-k. How many ways of renumbering are there?
The initial tree G is given as two
0-2-1 | 3Possible numberings are as follows.
0-1-2 0-1-3 2-1-3 3-1-2 2-1-0 3-1-0 | | | | | | 3 2 0 0 3 2 0-2-3 1-2-3 3-2-1 3-2-0 0-2-1 1-2-0 | | | | | | 1 0 0 1 3 3
5-0-1-2-4 | 3Possible ways:
0-1-2-3-4 0-1-2-3-5 | | 5 4 5-4-3-2-1 5-4-3-2-0 | | 0 1