How would you solve this graph theory handshake problem in python?

Last year I graduated from college with a degree in psychology, but I also learned a lot for fun. I recently got Gary Chartrand's Theory of Opening Charts book to refresh my math and have fun. Here is an exercise from a book that I find particularly stupefying:

Suppose you and your husband attended a party with three other married couples. A few handshakes place. No one shook hands with himself (or her) or with his (or her) spouse, and no one shook the hand of the same person more than once. After all the handshake has been completed, suppose you asked each person, including your husband, how many hands he or she shook. Each person has a different answer. a) How many hands do you shake? b) How many hands does your husband shake?

Now I thought about this for a while and tried to draw examples of graphs that could illustrate the solution, but I come empty-handed. My logic is this: on the graph there are 8 different vertices, and 7 of them have different degrees. Therefore, the values ​​for the degrees must be 0, 1, 2, 3, 4, 5, 6, and x. The number of degrees for one couple (0, 6). Since all graphs have an even number of odd vertices, x must be either 5, 3, or 1.

How do you solve this problem? And, if you could solve this in python, how would you do it?

(python is fun.)

Greetings.

+3
source share
2 answers

- , . . , (6,0). , . , 0,1,2,3,4, x (4,0). (5,1) . , , (6,0), (5,1), (4,2), (3,3). , , x = 3, 3 .

+1

, :

1 ->  {}
2 ->  {3, 4, 5, 6, 7, 8}
3 ->  {2, 5, 6, 7, 8}
4 ->  {2}
5 ->  {2, 3, 7, 8}
6 ->  {2, 3}
7 ->  {2, 3, 5}
8 ->  {2, 3, 5}

, , , . 8.

. , , 6, . , .

, , , (0,6) (1, 2, 3, 4, 5, x). , . "" , . "" , 1 . , (0, 1, 2, 3, 4, x-1), . , (0,6), (1,5). (0,4), 1 , , .

, - x, x = 3.

+1
source

Source: https://habr.com/ru/post/1746958/


All Articles