A degree sequence is a list of numbers representing the degrees of vertices in a graph. While it is difficult to tell if a graph can be made from a degree sequence, there are some ways to tell for certain that a graph does not exist with a given degree sequence. One easy first check is the following:
First, sort the degree sequence in descending order. Next, pop the first degree off the list and subtract one from the next N elements, where N is the degree you popped off. Repeat until the list is empty. If at any point a degree in the list is less than 0 or if there are not N elements left in the list to subtract from, there is no graph that exists with that degree sequence.
Write a function is_graph that returns true if this algorithm results in an empty list or false if it fails at any point.
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers11
Suggested Problems
-
Select every other element of a vector
37426 Solvers
-
Sort a list of complex numbers based on far they are from the origin.
5822 Solvers
-
Matrix with different incremental runs
598 Solvers
-
Is this triangle right-angled?
6684 Solvers
-
Numbers spiral diagonals (Part 1)
312 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!