I’m trying to implement a mutual friends feature using a graph data structure represented as an adjacency list in Python. Each node represents a person, and each edge represents a friendship (an undirected connection).
For example:
John — A, B, C, D
David — B, C, E, F
The mutual friends of John and David should be B and C.
What I Want to Improve ->I want to make this more efficient for larger networks (e.g., thousands of nodes). -> I’d like to know if there’s a better graph representation or built-in library that simplifies this task. ->How can I extend this to find mutual friends among more than two users (e.g., common friends of John, David, and Alex)?