Latest / CyberSecurity Summary / Algorithms, Part II
Transcript
- 0:00Speaker 1: So usually when you look at a map of a city,
- 0:03Speaker 1: there is this expectation of like static geography. You know,
- 0:07Speaker 1: you see the roads, you see the intersections, right, the
- 0:09Speaker 1: little blue line for the river. Yeah, exactly. The map
- 0:12Speaker 1: just sits there and basically says, you know, here's where
- 0:14Speaker 1: things are.
- 0:15Speaker 2: It feels like a.
- 0:15Speaker 3: Fixed picture, just a rigid grid of reality.
- 0:19Speaker 1: But then you open up a routing app on your
- 0:21Speaker 1: phone and you punch in a destination and suddenly that
- 0:25Speaker 1: static map just comes alive. It's instantaneously calculating I mean,
- 0:31Speaker 1: millions of possibilities, routing you around traffic and finding the
- 0:35Speaker 1: absolute optimal path. Well in a fraction of a second.
- 0:39Speaker 2: Yeah, the map isn't just a picture anymore.
- 0:40Speaker 1: At that point, exactly, You're suddenly looking at this invisible,
- 0:43Speaker 1: underlying architecture that really governs how everything in our world connects.
- 0:47Speaker 3: It is the absolute definition of a hidden mathematical engine.
- 0:52Speaker 3: And that engine is what we call.
- 0:54Speaker 1: A graph, and that invisible architecture is exactly what we
- 0:58Speaker 1: are mapping out today. Welcome to today's deep dive. We
- 1:02Speaker 1: are diving deep into the science of graphs.
- 1:04Speaker 3: And just to be absolutely clear, right out of the gate,
- 1:07Speaker 3: we are not talking about like the bar charts or
- 1:10Speaker 3: the line graphs from high.
- 1:12Speaker 1: School algebra, right, No pie charts here, No, no.
- 1:14Speaker 3: No, We are talking about mathematical models of pairwise connections.
- 1:17Speaker 3: So we have vertices which are the items themselves, and
- 1:20Speaker 3: we have edges which are the connections between them.
- 1:23Speaker 1: And the sheer ubiquity of this model in our source
- 1:27Speaker 1: material is staggering. I mean, whether you're looking at a roadmap,
- 1:31Speaker 1: the World Wide Web, an electric circuit, or a massive
- 1:35Speaker 1: social network, you are looking at a graph.
- 1:38Speaker 3: Absolutely, And the goal of our deep dive today is
- 1:41Speaker 3: to really explore how computer science uses these incredibly simple
- 1:45Speaker 3: models to solve seemingly impossible logistical scheduling and routing problems
- 1:52Speaker 3: in just mere milliseconds.
- 1:54Speaker 1: Yeah, We're going to start with simple two way connections,
- 1:56Speaker 1: figure out how a computer explores them without getting lost,
- 1:58Speaker 1: and then we'll look at the complications of like one
- 2:00Speaker 1: way streets, which gets messy, oh very and finally we
- 2:04Speaker 1: will add actual costs to those paths. By the end,
- 2:07Speaker 1: we're answering questions ranging from you know, how the Java
- 2:10Speaker 1: programming language manages your computer's memory to how you calculate
- 2:14Speaker 1: your exact Kevin Bacon number.
- 2:16Speaker 3: I love that one, But we do have to start
- 2:18Speaker 3: with the fundamental blueprint though, right.
- 2:20Speaker 1: So the most basic model we have, Yeah.
- 2:22Speaker 3: It's called the undirected graph. In an undirected graph, the
- 2:26Speaker 3: edges are simply two way connections. So if vertex A
- 2:30Speaker 3: is connected to vertex B, then B is connected to A.
- 2:33Speaker 1: It's perfectly semetic, right, a standard two way street exactly.
- 2:37Speaker 3: But the immediate challenge when you want to put this
- 2:39Speaker 3: into a computer is how to represent it without just
- 2:42Speaker 3: blowing through massive amounts of memory.
- 2:44Speaker 1: Because I mean, if you have a massive network, say
- 2:46Speaker 1: billions of users on a social network, most people don't
- 2:49Speaker 1: know most other people, like, the connections are really sparse.
- 2:52Speaker 2: Yeah, they are.
- 2:53Speaker 3: And the intuitive way to represent this might be like
- 2:55Speaker 3: a giant grid what we call an adjacency matrix. Imagine
- 2:59Speaker 3: every single vertex has its own row and its own column,
- 3:02Speaker 3: and you just put a check mark where they intersect.
- 3:04Speaker 1: Okay, makes sense in theory, in.
- 3:06Speaker 3: Theory, sure, but for a network of millions, a matrix
- 3:09Speaker 3: takes up a prohibitive amount of space. You'd have this
- 3:12Speaker 3: massive grid where you know, ninety nine point nine percent
- 3:15Speaker 3: of the boxes.
- 3:16Speaker 2: Are just empty.
- 3:17Speaker 3: Oh wow, Yeah, it's a colossal waste of computing resources.
- 3:20Speaker 1: So to fix that, the standard approach the sources talk
- 3:23Speaker 1: about is an adjacency list's data structure.
- 3:26Speaker 2: Right.
- 3:26Speaker 1: You basically just keep a master array of your vertices,
- 3:29Speaker 1: and for every single one you attach a simple, really
- 3:32Speaker 1: short list of only the vertices it actually connects to.
- 3:35Speaker 3: You don't record the absences, only the presences.
- 3:38Speaker 1: Yeah, it's elegant, and it saves exactly enough space to
- 3:42Speaker 1: make processing huge graphs possible.
- 3:45Speaker 3: But which you have your graph efficiently stored in the computer,
- 3:48Speaker 3: you still need a way to explore it. And sources
- 3:51Speaker 3: bring up this amazing historical.
- 3:52Speaker 1: Analogy for this, oh, dating back to antiquity, right, Trimo
- 3:55Speaker 1: mays exploration. Yes, I really love this concept. So for
- 3:59Speaker 1: you listen, imagine wandering through a massive physical maze. To
- 4:03Speaker 1: avoid getting hopelessly lost, you carry a ball of string. Right.
- 4:08Speaker 1: You unroll the string behind you as you walk down
- 4:11Speaker 1: any unvisited passage. When you hit an intersection, you mark
- 4:15Speaker 1: it with chalk, so you know you've been there. If
- 4:17Speaker 1: you hit a dead end or you know an intersection
- 4:19Speaker 1: you've already marked, you just turn around and use your
- 4:22Speaker 1: string to retrace your steps until you find a passage
- 4:25Speaker 1: you haven't gone.
- 4:25Speaker 3: Down yet in that physical process.
- 4:28Speaker 1: Ye.
- 4:28Speaker 3: That is the exact mechanism of one of the most
- 4:31Speaker 3: fundamental algorithms in computer science. It's called depth first search
- 4:35Speaker 3: or DFS.
- 4:36Speaker 1: DFS.
- 4:37Speaker 3: Yeah, you follow a path as deeply into the graph
- 4:40Speaker 3: as you possibly can until you hit a dead end,
- 4:43Speaker 3: marking vertices as you visit them. Then you literally retrace
- 4:46Speaker 3: your steps back to the last intersection that had an
- 4:49Speaker 3: unexplored edge.
- 4:50Speaker 1: And that string translates perfectly to a computer's memory, right
- 4:53Speaker 1: because DFS uses what.
- 4:54Speaker 3: We call a stack exactly, a stack.
- 4:56Speaker 1: Which operates on a last in, first out role. So
- 4:59Speaker 1: the last inner sec you pass is the very first
- 5:01Speaker 1: one you return to when you need to backtrack.
- 5:03Speaker 3: It explores the graph by basically looking for new vertices
- 5:06Speaker 3: far away from the start point, and it only takes
- 5:08Speaker 3: closer vertices when it hits those dead ends. There's a
- 5:11Speaker 3: butt there is what if you don't just want to
- 5:14Speaker 3: explore the graph, What if you specifically want to find
- 5:18Speaker 3: the shortest path between two points. Depth first search doesn't
- 5:21Speaker 3: help much there, because it might take you on a
- 5:25Speaker 3: massive winding detour just based on which arbitrary path you
- 5:28Speaker 3: chose to go down first right.
- 5:30Speaker 1: Because you're just picking a hallway and running. So if
- 5:33Speaker 1: DFS is a single person running as far as they
- 5:35Speaker 1: can down one winding hallway, bread first search or BFS
- 5:40Speaker 1: is well, it's like dropping a stone in a pond.
- 5:42Speaker 2: Oh, that's a great way to put it.
- 5:44Speaker 1: The search ripples outward perfectly. You fan out in all
- 5:47Speaker 1: directions at once, You check everywhere that is exactly one
- 5:50Speaker 1: step away. Then only after that one step ring is
- 5:54Speaker 1: completely checked, the search expands to everywhere that is two
- 5:56Speaker 1: steps away, and so on and programmatically.
- 5:59Speaker 3: The difference is incredibly subtle but profound. Instead of a stack,
- 6:03Speaker 3: breadth first search.
- 6:04Speaker 1: Uses a q Q right first and first out.
- 6:07Speaker 3: Like waiting in line at a grocery store. It explores
- 6:10Speaker 3: the oldest discovered intersections first. This guarantees that when you
- 6:14Speaker 3: finally find the vertex you're looking for, you have found
- 6:17Speaker 3: the absolute shortest paths.
- 6:18Speaker 1: To get there, because you literally already checked every single
- 6:22Speaker 1: path that was shorter exactly.
- 6:23Speaker 2: You couldn't have missed a shorter way.
- 6:25Speaker 1: So we've been talking about these vertices as like abstract
- 6:30Speaker 1: numbers vertex zero, vertex one, but in the real world,
- 6:33Speaker 1: data doesn't.
- 6:34Speaker 3: Really look like that no, it rarely does, and that
- 6:37Speaker 3: brings in what we call symbol graphs.
- 6:39Speaker 1: Right.
- 6:39Speaker 3: In a symbol graph, the vertices aren't just integers, they
- 6:42Speaker 3: are strings of text. So they are airport codes like
- 6:45Speaker 3: JFK or LAX, or IP addresses or movie titles.
- 6:51Speaker 1: And the source material uses the Kevin Bacon game as
- 6:54Speaker 1: the perfect example of this. They use an Internet movie
- 6:57Speaker 1: database file.
- 6:58Speaker 2: Yes, the classic game.
- 6:59Speaker 1: For anyone who hasn't played. The goal is to connect
- 7:01Speaker 1: any actor to Kevin Bacon through the movies they've co
- 7:03Speaker 1: starred in. But looking at this as a graph, there
- 7:06Speaker 1: is a fascinating structural detail here.
- 7:08Speaker 2: Yeah, it's a bipartite graph.
- 7:09Speaker 1: A bipartite graph. Break that down.
- 7:11Speaker 3: So a bipartite graph is a network where the vertices
- 7:15Speaker 3: could be divided into two completely distinct sets, and the
- 7:19Speaker 3: key is edges only connect to vertex in one set
- 7:23Speaker 3: to a vertex in the other.
- 7:24Speaker 1: Okay, So in this case, the two sets are movies
- 7:27Speaker 1: and actors.
- 7:27Speaker 3: Right, Movies only connect to actors who are in them,
- 7:30Speaker 3: and actors only connect to the movies they acted in.
- 7:33Speaker 1: So there's no direct actor to actor edge and no
- 7:36Speaker 1: movie to movie edge.
- 7:37Speaker 3: You have to alternate exactly. And if you apply our
- 7:40Speaker 3: breadth first search algorithm to this bipartite symbol graph, you
- 7:44Speaker 3: effortlessly find the shortest alternating path. Wow, you started the
- 7:47Speaker 3: Kevin Bacon vertex. Ripple out to all the movies he
- 7:50Speaker 3: was in. That's a distance of one. Then you ripple
- 7:52Speaker 3: out to all the actors and all those.
- 7:53Speaker 1: Movies, so all those actors have a Kevin Bacon number
- 7:56Speaker 1: of one.
- 7:56Speaker 2: Right.
- 7:57Speaker 3: Then you sweep to all the other movies those actors
- 7:59Speaker 3: were in, and so on. The BFS algorithm sweeps through
- 8:02Speaker 3: the database and instantaneously proves the Bacon number for anyone.
- 8:06Speaker 1: And you could use the exact same logic to find
- 8:09Speaker 1: your Urdo's number if you're a mathematician based on like
- 8:12Speaker 1: co authored papers, or even a Bruce Springsteen number to
- 8:16Speaker 1: connect musicians. It's the exact same underlying architecture.
- 8:20Speaker 3: It is, but there's a massive blind spot here.
- 8:23Speaker 1: Okay, what's the blind spot?
- 8:24Speaker 3: The Kevin Bacon game assumes mutual relationships, like if I
- 8:29Speaker 3: worked with you, you worked with me. Two way streets are
- 8:32Speaker 3: great for modeling a movie cast or a physical road network,
- 8:35Speaker 3: But what happens when the world isn't mutual.
- 8:38Speaker 1: Oh, like, what if a webpage links to you but
- 8:40Speaker 1: you don't link.
- 8:41Speaker 3: Back exactly, or a one way street in a city.
- 8:44Speaker 3: This brings in directographs or digraphs.
- 8:46Speaker 1: Digraphs. Okay, so if we are just adding a directional
- 8:49Speaker 1: arrow to the etch, how much harder can this really
- 8:51Speaker 1: beat a process?
- 8:52Speaker 2: Like?
- 8:52Speaker 1: Does our ball of string from the maze still work?
- 8:55Speaker 3: It gets profoundly harder because the moment you introduce direction
- 8:59Speaker 3: reach A bility is no longer symmetric. In a standard graph,
- 9:02Speaker 3: if vertex A can reach vertex B, B can obviously
- 9:06Speaker 3: reach A. In a digraph, the fact that A have
- 9:08Speaker 3: a path to B tells you absolutely nothing about whether
- 9:12Speaker 3: B can get back to A. It completely changes the
- 9:15Speaker 3: topological structure.
- 9:16Speaker 1: But the depth for search algorithm still works to find
- 9:19Speaker 1: out what is reachable, right it only follows the arrows.
- 9:23Speaker 3: Yes, it does. And a critical real world application of
- 9:27Speaker 3: this one way reachability is actually going on inside your
- 9:31Speaker 3: computer's ram right now?
- 9:32Speaker 1: Eait really?
- 9:33Speaker 2: Yeah?
- 9:33Speaker 3: Specifically in Java's mark and sweep garbage collection.
- 9:36Speaker 1: Garbage collection that sounds like something a sanitation truck does
- 9:39Speaker 1: not a programming language, well.
- 9:41Speaker 3: In memory management, it's absolutely essential. So a running program
- 9:44Speaker 3: creates countless objects in memory. The computer treats all those
- 9:48Speaker 3: objects as vertices in a giant digraph, and the references
- 9:52Speaker 3: from one object to another are the directed edges. Okay, periodically,
- 9:56Speaker 3: the system just pauses and runs a digraph reachability algorithm
- 10:00Speaker 3: starting from the main program. It marks every object it
- 10:02Speaker 3: can reach by following those one way.
- 10:04Speaker 1: Arrows, and anything that doesn't get marked is no.
- 10:06Speaker 3: Longer connected to the active program. It's digital garbage. The
- 10:10Speaker 3: system then sweeps those unmarked objects away to free up memory.
- 10:15Speaker 1: Wow, so it's just unrolling the tremo string through your
- 10:17Speaker 1: computer's memory. That's incredible.
- 10:19Speaker 2: It really is.
- 10:20Speaker 1: Another huge area where these one way arrows matter is scheduling.
- 10:24Speaker 1: So think about planning a college course schedule. You have
- 10:27Speaker 1: strict prerequisites. Oh wow, you know you have to take
- 10:30Speaker 1: introduction to CS before you can take advanced programming. You
- 10:34Speaker 1: have to take calculus before linear algebra.
- 10:36Speaker 3: This is a classic precedence constrained scheduling problem. The vertices
- 10:41Speaker 3: are the courses and the directed ages are the prerequisites
- 10:44Speaker 3: pointing from the requirement to the advanced class. The goal
- 10:48Speaker 3: is to put all these vertices in a straight line,
- 10:50Speaker 3: an order where every single arrow points forward. You can't
- 10:54Speaker 3: take a class before. It's prerequisite in graph processing, finding
- 10:57Speaker 3: this order is called a topological sort.
- 11:00Speaker 1: Okay, but hold on, that assumes everyone follows the rules.
- 11:02Speaker 1: What if the registrar completely screws up. What if course
- 11:05Speaker 1: A requires course B, course B requires course C, but
- 11:09Speaker 1: course C requires Course.
- 11:10Speaker 3: A, then you have a massive problem. That is what
- 11:13Speaker 3: we call a directed cycle. If you trace the arrows,
- 11:16Speaker 3: you end up right back where you start it right.
- 11:18Speaker 3: If a graph has a directed cycle, scheduling is completely impossible.
- 11:22Speaker 3: No one can ever graduate.
- 11:24Speaker 1: It's the ultimate bureaucratic catch twenty two exactly.
- 11:28Speaker 3: Therefore, topological sorts only work on a very specific type
- 11:32Speaker 3: of graph, a day EAG, which stands for directed a
- 11:36Speaker 3: cyclic graph, a cyclic meaning containing no cycles.
- 11:39Speaker 1: So before you can even try to schedule the classes,
- 11:42Speaker 1: you have to use a search algorithm just to prove
- 11:44Speaker 1: there are no cycles hiding in the rule book and the.
- 11:46Speaker 3: Exact same depth first search we've been talking about solves
- 11:49Speaker 3: this too, by keeping track of the path that's currently
- 11:52Speaker 3: exploring the straying.
- 11:53Speaker 2: In our maze.
- 11:54Speaker 3: If it ever encounters a vertex that is already on
- 11:57Speaker 3: its current path, it has found a cycle. Ah, if
- 12:00Speaker 3: it explores a whole graph, it never hits its own string.
- 12:02Speaker 3: It's officially a dag and the schedule.
- 12:04Speaker 2: Can be made.
- 12:05Speaker 1: Okay, So cycles ruined schedules. We hate cycles and we
- 12:08Speaker 1: want things in a straight line. But what if a
- 12:11Speaker 1: cycle is exactly what we are looking for.
- 12:13Speaker 3: Then we are looking for strong components and strong connectivity.
- 12:17Speaker 1: Okay, break that down.
- 12:18Speaker 3: Two vertices are strongly connected if they are mutually reachable.
- 12:22Speaker 3: So if there is a directed path from A to B,
- 12:24Speaker 3: in a directed path from B back to A, this
- 12:27Speaker 3: inherently means they're part of a directed cycle, right they loop.
- 12:30Speaker 3: A strong component is a cluster of vertices that are
- 12:33Speaker 3: all mutually reachable from one another.
- 12:35Speaker 1: And the source material uses the example of an ecological
- 12:38Speaker 1: food web for this, which really helped me visualize it.
- 12:41Speaker 1: Imagine a massive digraph where the vertices are species and
- 12:46Speaker 1: the directed edges point from predator to prey. Identifying the
- 12:51Speaker 1: strong components in this massive web allows ecologists to understand
- 12:54Speaker 1: isolated energy flows. If a group of species are all
- 12:58Speaker 1: mutually reachable in this web represents a self contained cycle
- 13:01Speaker 1: of energy and nutrients.
- 13:03Speaker 2: That's a great example.
- 13:04Speaker 1: Or think about the world wide Web finding strong components
- 13:07Speaker 1: clusters together hyperlinked pages that all reference each other, which
- 13:11Speaker 1: helps search engines categorize the Internet.
- 13:13Speaker 3: But computationally finding these massive, intertwined clusters of mutual reachability
- 13:19Speaker 3: in a network of millions of vertices it seems like
- 13:22Speaker 3: an impossibly complex task. If reachability isn't symmetric, how do
- 13:28Speaker 3: you efficiently group everyone who can reach everyone else?
- 13:32Speaker 1: Yeah? When I read the steps for this in the
- 13:34Speaker 1: source material, it seemed like actual magic. It's called the
- 13:37Speaker 1: Cosaraji Sharer algorithm.
- 13:40Speaker 2: It is brilliant.
- 13:40Speaker 3: It finds all the strong components in a digraph in
- 13:43Speaker 3: linear time. The steps are deceptively simple.
- 13:45Speaker 1: Okay, walk us through it.
- 13:47Speaker 3: First, you take your digraph and you reverse every single
- 13:49Speaker 3: era you compute the reverse graph. Okay, Then you run
- 13:52Speaker 3: a search on that reverse graph, but you aren't just
- 13:54Speaker 3: looking around. You're keeping a very specific list. You record
- 13:57Speaker 3: the order in which the search finishes explod oring of
- 14:00Speaker 3: Vertex's path, essentially ranking who hits.
- 14:03Speaker 1: A dead end last, tracking the dead ends.
- 14:04Speaker 3: Got it? Then you use that specific reverse order to
- 14:07Speaker 3: run your second search on the original unreversed graph.
- 14:10Speaker 1: Let me stop and explain why flipping the arrows actually works,
- 14:13Speaker 1: because this is where the genius really lies for me.
- 14:16Speaker 2: Please do.
- 14:17Speaker 1: If you are exploring a graph and you wander into
- 14:20Speaker 1: a strongly connected cluster, the danger is that you might
- 14:23Speaker 1: accidentally follow an arrow that leads out of the cluster
- 14:26Speaker 1: to some other random part of the graph, and since
- 14:28Speaker 1: it's a one way street, you can't get back. You
- 14:30Speaker 1: just bleed out into the rest of the web.
- 14:32Speaker 3: Yes, exactly, you lose the cluster. By reversing the arrows
- 14:36Speaker 3: and ranking who hits dead end's last, you are essentially
- 14:40Speaker 3: finding the sinks, the places where flow pulls up. Wow.
- 14:44Speaker 3: When you run the second search using that specific order,
- 14:48Speaker 3: you guarantee that you are always starting in a cluster
- 14:51Speaker 3: where the only outgoing arrows have either been reversed or
- 14:54Speaker 3: point to things you've already found. It artificially traps the
- 14:57Speaker 3: search algorithm inside the cluster. It can't bleed up right,
- 15:00Speaker 3: so every time the search finishes its local sweep, that
- 15:03Speaker 3: isolated bucket of vertices is exactly one strong component.
- 15:07Speaker 1: You just run a search, flip the graph and run
- 15:09Speaker 1: it again, and boot the complex ecosystem of predator and prey,
- 15:13Speaker 1: or the clustered communities of the World Wide Web. It
- 15:15Speaker 1: just falls out into perfectly organized buckets.
- 15:18Speaker 2: Beautiful.
- 15:18Speaker 1: It is absolutely breathtaking that something so complex is solved
- 15:22Speaker 1: by manipulating the flow like that.
- 15:25Speaker 3: It's a testinate to how deeply understanding the mathematical properties
- 15:28Speaker 3: of the graph yeah, allows you to manipulate it. But
- 15:32Speaker 3: as we move forward, we have to recognize that in
- 15:34Speaker 3: the real world, navigating connections isn't just about whether a
- 15:38Speaker 3: path exists.
- 15:39Speaker 1: Right, so far, all these connections we've talked about are free.
- 15:42Speaker 1: You either have an edge or you don't. But in reality,
- 15:44Speaker 1: taking a street costs something, which introduces us to edge
- 15:48Speaker 1: weighted graphs.
- 15:49Speaker 3: We assign a value or a weight to every single connection.
- 15:54Speaker 1: And my immediate assumption was that an edgeweight is obviously
- 15:56Speaker 1: the physical distance between two points, like the miles between
- 16:00Speaker 1: to airports on a routing map.
- 16:01Speaker 3: Yeah, that's a very common misconception. Edgeweights can represent physical distance, yes,
- 16:06Speaker 3: but they can also represent the monetary cost of a flight,
- 16:09Speaker 3: or the time it takes for a signal to travel
- 16:11Speaker 3: down a wire, or.
- 16:12Speaker 2: Even the amount of fuel burned.
- 16:13Speaker 3: Okay, In fact, edgeways don't even have to be positive.
- 16:16Speaker 2: They could be zero or even negative values.
- 16:19Speaker 1: Wait, how can a cost be negative.
- 16:21Speaker 3: Well, imagine a financial graph modeling currency exchange or stock transactions.
- 16:27Speaker 3: A negative weight might represent a guaranteed profit margin on
- 16:30Speaker 3: a trade. The math of the graph doesn't care what
- 16:33Speaker 3: the number represents, It just knows it needs to optimize it.
- 16:36Speaker 1: Okay, that makes sense, and one of the most famous
- 16:39Speaker 1: optimization problems is finding the minimum spanning tree or MST.
- 16:43Speaker 2: Right.
- 16:44Speaker 1: The goal here is to find a set of edges
- 16:46Speaker 1: that connects every single vertex in the graph without any cycles,
- 16:49Speaker 1: and doing it with the absolute minimum total edge weight possible.
- 16:53Speaker 3: And this is a profoundly important problem. If you are
- 16:56Speaker 3: laying electrical wiring for a new neighborhood, or laying fiber
- 16:59Speaker 3: optic network cables across an ocean, or even designing the
- 17:02Speaker 3: routing topology for an airline, you need to connect everything
- 17:06Speaker 3: using the absolute minimum amount of resources.
- 17:09Speaker 1: But finding the minimum spanning tree without just guessing and
- 17:12Speaker 1: checking trillions of combinations, that requires something called the cut property.
- 17:16Speaker 2: Think about it intuitively.
- 17:17Speaker 3: Imagine taking all the vertices in your graph and drawing
- 17:20Speaker 3: a line that divides them into two completely isolated islands,
- 17:24Speaker 3: group A and group B.
- 17:25Speaker 1: Okay, two islands.
- 17:26Speaker 3: Now, look at all the potential edges that could cross
- 17:29Speaker 3: the water to connect those two islands. The cut property
- 17:32Speaker 3: says that if you want to build a spanning tree,
- 17:35Speaker 3: you absolutely have to build at least one bridge to
- 17:38Speaker 3: connect them. If you want to keep your overall cost down,
- 17:42Speaker 3: why wouldn't you pick the absolute cheapest bridge available. The
- 17:46Speaker 3: property mathematically proves that the crossing edge with the absolute
- 17:49Speaker 3: minimum weight must be part of the minimum spanning tree.
- 17:53Speaker 1: So any random cut, as long as you divide the
- 17:56Speaker 1: graph into two, the cheapest edge bridging that gap is
- 17:59Speaker 1: guaranteed to be in the final optimal tree.
- 18:02Speaker 2: Any cut it.
- 18:02Speaker 1: All that is wild, And this leads to what computer
- 18:06Speaker 1: scientists call a greedy algorithm. Yes, greedy algorithms are amazing
- 18:10Speaker 1: because they seem almost too simple to work. A greedy
- 18:12Speaker 1: algorithm basically just says, at every single step, look at
- 18:15Speaker 1: the options right in front of you and just grab
- 18:17Speaker 1: the cheapest one. Don't worry about the big picture, don't
- 18:20Speaker 1: plan ten steps ahead, just make the best cheapest local
- 18:24Speaker 1: choice right now.
- 18:26Speaker 3: It is counterintuitive, isn't it, And a lot of areas
- 18:28Speaker 3: in life making the greedy short term choice leads a
- 18:32Speaker 3: disaster down the road. Oh absolutely, But because of the
- 18:34Speaker 3: cut property in the minimum spanning tree problem. Continually making
- 18:39Speaker 3: the greedy local choice mathematically guarantees that you will end
- 18:43Speaker 3: up with the perfect optimal global solution.
- 18:47Speaker 1: You just keep gobbling up the cheapest connection that doesn't
- 18:49Speaker 1: form a cycle, and when you've connected everything, you were
- 18:52Speaker 1: holding the perfect blueprint for your power grid or your network.
- 18:55Speaker 3: It highlights a recurring theme in graph processing. Complex global
- 18:59Speaker 3: problem often have elegant solutions if you can just identify
- 19:02Speaker 3: the right local rule to follow.
- 19:04Speaker 1: Man, what an incredible journey we just took.
- 19:06Speaker 2: Yeah, we covered a lot of ground.
- 19:08Speaker 1: We started out literally unrolling a ball of string to
- 19:11Speaker 1: get through a basic maze. Then we use that same
- 19:14Speaker 1: ripple effect to reveal the hidden bipartite web of Kevin
- 19:18Speaker 1: Bacon's movie career. We wrangled chaotic, impossible college schedules by
- 19:22Speaker 1: proving they were directed as cicclet graphs. We trapped cycles
- 19:26Speaker 1: to find mutually assured survival and food webs using the
- 19:29Speaker 1: sheer brilliance of the Kasarda Sharier algorithm. And finally we
- 19:33Speaker 1: routed the cheapest possible power grade using nothing but a
- 19:36Speaker 1: greedy local choice.
- 19:37Speaker 3: Abstract mathematical models really are the silent force powering our
- 19:41Speaker 3: modern infrastructure. But I do want to leave you with
- 19:44Speaker 3: one final mind expanding thought, straight from the exercises in
- 19:47Speaker 3: our source material.
- 19:49Speaker 1: Ooh, lay it on us.
- 19:50Speaker 3: We've talked a lot about maps, computers, and social networks today,
- 19:54Speaker 3: but mathematical chemists used the exact same graph logic we
- 19:58Speaker 3: discussed today to analyze the build holding blocks of the
- 20:00Speaker 3: universe on They use something called the Wiener index. It's
- 20:04Speaker 3: calculated by summing the lengths of the shortest paths between
- 20:07Speaker 3: all pairs of vertices in a graph. But in their graphs,
- 20:10Speaker 3: the vertices are atoms and the egges are chemical bonds.
- 20:13Speaker 1: Wow. Think about that for a second. The exact same
- 20:17Speaker 1: algorithmic logic your phone's map app uses to route your
- 20:20Speaker 1: car around a traffic jam is simultaneously being used by
- 20:23Speaker 1: scientists to decode the shape, the behavior, and the fundamental
- 20:27Speaker 1: structure of the microscopic molecules inside your own body.
- 20:30Speaker 3: The rules of the graph apply the matter the scale.
- 20:34Speaker 1: It really makes you look differently at that city map
- 20:36Speaker 1: we started with. It's not just a picture of streets.
- 20:39Speaker 1: It's a reflection of the invisible architecture that connects literally everything, atoms, actors,
- 20:44Speaker 1: internet pages and you. Everything is connected, and now you
- 20:48Speaker 1: know how to map it.