# GATE | GATE CS 2010 | Question 28

The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in decreasing order. Which of the following sequences can not be the degree sequence of any graph?

(I) 7, 6, 5, 4, 4, 3, 2, 1 (II) 6, 6, 6, 6, 3, 3, 2, 2 (III) 7, 6, 6, 4, 4, 3, 2, 2 (IV) 8, 7, 7, 6, 4, 2, 1, 1

**(A)** I and II**(B)** III and IV**(C)** IV only**(D)** II and IV**Answer:** **(D)****Explanation:** A generic algorithm or method to solve this question is

Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in **GATE Test Series Course**.

Learn all **GATE CS concepts with Free Live Classes** on our youtube channel.

1: procedure isV alidDegreeSequence(L)

2: for n in list L do

3: if L doesn’t have n elements next to the current one then return false

4: decrement next n elements of the list by 1

5: arrange it back as a degree sequence, i.e. in descending order

6: if any element of the list becomes negative then return false

7: return true

Rationale behind this method comes from the properties of simple graph. Enumerating the f alse returns, 1) if L doesn’t have enough elements after the current one or 2) if any element of the list becomes negative, then it means that there aren’t enough nodes to accommodate edges in a simple graph fashion, which will lead to violation of either of the two conditions of the simple graph (no self-loops and no multiple-edges between two nodes), if not others.

See http://www.geeksforgeeks.org/data-structures-and-algorithms-set-25/

This solution is contributed by **Vineet Purswani.**

**Another one:**

A degree sequence d1,d2,d2. . . dn of non negative integer is graphical if it is a degree sequence of a graph. We now introduce a powerful tool to determine whether a particular sequence is graphical due to Havel and Hakimi

**Havel–Hakimi Theorem :**

→ According to this theorem, Let D be sequence the d1,d2,d2. . . dn with d1 ≥ d2 ≥ d2 ≥ . . . dn for n≥ 2 and di ≥ 0.

→ Then D0 be the sequence obtained by:

→ Discarding d1, and

→ Subtracting 1 from each of the next d1 entries of D.

→ That is Degree sequence D0 would be : d2-1, d2-1, d3-1 . . . , dd1+1 -1 . . . , dn

→ Then, D is graphical if and only if D0 is graphical.

Now, we apply this theorem to given sequences:

option I) 7,6,5,4,4,3,2,1 → 5,4,3,3,2,1,0 → 3,2,2,1,0,0 → 1,1,0,0,0 → 0,0,0,0 so its graphical.

Option II) 6,6,6,6,3,3,2,2 → 5,5,5,2,2,1,2 ( arrange in ascending order) → 5,5,5,2,2,2,1 → 4,4,1,1,1,0 → 3,0,0,0,0 → 2,-1,-1,-1,0 but d (degree of a vertex) is non negative so its not a graphical.

Option III) 7,6,6,4,4,3,2,2 → 5,5,3,3,2,1,1 → 4,2,2,1,1,0 → 1,1,0,0,0 → 0,0,0,0 so its graphical.

Option IV) 8,7,7,6,4,2,1,1 , here degree of a vertex is 8 and total number of vertices are 8 , so it’s impossible, hence it’s not graphical.

Hence only option I) and III) are graphic sequence and answer is option-D

This solution is contributed by** Nirmal Bharadwaj.**

Quiz of this Question