Skip to Main Content
Graph Algorithms the Fun Way
book

Graph Algorithms the Fun Way

by Jeremy Kubica
November 2024
Intermediate to advanced content levelIntermediate to advanced
416 pages
11h 11m
English
No Starch Press
Content preview from Graph Algorithms the Fun Way

C UNION-FIND

Kruskal’s algorithm, randomized maze generation, and single-linkage clustering from Chapter 10 all use a data structure called UnionFind to represent the disjoint sets of nodes corresponding to the different connected components in a graph. This data structure allows the algorithms to efficiently (1) determine whether two nodes are already in the same connected component and (2) merge two different components. For completeness, this appendix describes and provides the code for this data structure.

We begin by providing a very brief overview of union-find data structures, followed by just enough code to implement the algorithms ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Algorithms, Second Edition

Grokking Algorithms, Second Edition

Aditya Bhargava
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
Algorithms: 24-part Lecture Series

Algorithms: 24-part Lecture Series

Robert Sedgewick, Kevin Wayne

Publisher Resources

ISBN: 9781098182519Errata Page