August 2024
Intermediate to advanced
516 pages
11h 47m
English
In some social networks, relationships are not mutual. For example, a social network may allow Alice to follow Bob, but Bob doesn’t have to follow Alice back. Let’s construct a new graph that demonstrates who follows whom:

This is known as a directed graph. In this example, the arrows indicate the direction of the relationship. Alice follows both Bob and Cynthia, but no one follows Alice. We can also see that Bob and Cynthia follow each other.
We can still use our simple hash-table implementation to store this data:
| | followees = { |
| | "Alice": ["Bob", "Cynthia"], |
| | "Bob": ["Cynthia"], |
| | "Cynthia": ["Bob"] |
| | } |
The only ...
Read now
Unlock full access