Graph
A structure of nodes joined by connections, where any element can connect with any other. It holds many-to-many relationships.
Example
A social network: Ana is friends with 300 people, and each of them has their own 300 friends.
Test yourself: Graph
Types of structures
Friendships on a social network, where each person has many friends, are best stored in…
If Ana has 300 friends and each has another 300, the relationship isn't single-parent: it's a network. That's a graph.
Graphs
What's best modeled with a graph?
Montevideo connects with 5 cities and each of them with others: many-to-many relationships. The line and the stack are linear.
Graphs
On a directed social network, an account with 1,000 followers has an ___-degree of 1,000.
Followers are edges arriving at the account. The accounts it follows are its out-degree, for example 150.
0/3
â–¶ PlayLessons that use it
What is an algorithm
You already use algorithms
Iteration and recursion
2 ways to repeat
Space complexity
How much memory it asks for
Types of structures
How they relate and where they live
Arrays
Adjacent cells
Linked lists
Links of a chain
Graphs
Points and connections
Graph operations
Adding and removing vertices and edges
Walking a graph
BFS and DFS, now with cycles
Greedy algorithms
The best right now
Databases
Where data is kept
NoSQL databases
Beyond tables
SQL or NoSQL
Picking the right database
GraphQL and gRPC
Other ways to talk to an API
Designing Twitter
1 billion tweets a day
