🏅 Beginner diploma - CyCognito/clojure-course GitHub Wiki
🤝 A social graph
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, without using any atoms:
- Add a member
- Remove a member
- Add friendship
- Remove friendship
Remark: Make sure the main functions have a docstring (at least 5 functions!)
Step 1
Think about how to represent the social graph with immutable data structures.
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 return a new version of the graph.
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.