Skip to content

Intermediate diploma

Yehonathan Sharvit edited this page Feb 23, 2021 · 3 revisions

Your mission is to create a social graph and to write functions that answer questions about the social graph:

Are two members friends? What's the average number of friends? Given two friends, calculate how many friends they have in common BONUS: Are two members connected through a friendship path (Dijsktra algo might help)? Also, please write functions that change the graph:

Add a member Remove a member Add friendship Remove friendship Don't forget to write unit tests.

Step 1 Think about how to represent the social graph with immutable data structures and store the current version of the graph in an atom.

Write code that generate a graph with around 1000 members and 5000 friend relationships.

For sake of simplicity, you can represent a member with a string that contains the member name (and assume that no two members have the same name).

Remark: The name of the persons should be real names like David or Jessica. Not machine generated names like "xhcjhfjd".

Step 2 Write functions that add or remove members and friends. The functions should operate on the graph atom.

Step 3 Write functions that query the graph:

Are two members friends? What's the average number of friends of a member Are two members connected? Good luck!

Feel free to ask questions on Slack for clarification or 🆘 help.

Clone this wiki locally