Reference no: EM132368887
Question
You would appreciate some feedback as to how to start answering this question. e.g. what should i try to attempt using python thanks.
You have to analyse friendship groups on campus. Individuals have been allocated a number between 0 and the number of people on campus minus one, and their friendships have been recorded as edges between numbered vertices.
Assume friendships are always bi-directional. Cambridge has implemented this graph in a Python-readable format as an adjacency matrix.
Write the function society(graph matrix, person) which determines whether a person has two friends who are also friends with each other.
Input: a nested list graph matrix that represents a graph as an adjacency matrix, that models the friendships at Cambridge; and an integer person, where 0 ≤ person < number of people on campus.
Output: a boolean, True if person has at least two friends who are also friends with each other; otherwise False.
Examples
a) Calling society(cambridge matrix,0) returns True as 1 and 3 are both friends with 0.
b) Calling society(cambridge matrix,2) returns False as 2 is friends with 0 and 4, but 0 and 4 are not friends with each other.