13. Graphs

Graphs are one of the most versatile structures used in computer programming. The sorts of problems that graphs can help to solve are generally quite different from those we’ve dealt with thus far in this book. If you’re dealing with general kinds of data storage problems, you probably won’t need a graph, but for some problems—and they tend to be interesting ones—a graph is indispensable.

Our discussion of graphs is divided into two chapters. In this chapter we’ll cover the algorithms associated with unweighted graphs, show some algorithms that these graphs can represent, and present ...

Get Data Structures and Algorithms in Java, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.