Skip to Content
Algorithms in a Nutshell, 2nd Edition
book

Algorithms in a Nutshell, 2nd Edition

by George T. Heineman, Gary Pollice, Stanley Selkow
December 2015
Intermediate to advanced
350 pages
10h 31m
English
O'Reilly Media, Inc.
Content preview from Algorithms in a Nutshell, 2nd Edition

Chapter 6. Graph Algorithms

Graphs are fundamental structures that represent complex structured information. The images in Figure 6-1 are all sample graphs.

In this chapter, we investigate common ways to represent graphs and associated algorithms that frequently occur. Inherently, a graph contains a set of elements, known as vertices, and relationships between pairs of these elements, known as edges. We use these terms consistently in this chapter; other descriptions might use the terms “node” and “link” to represent the same information. We consider only simple graphs that avoid (a) self-edges from a vertex to itself, and (b) multiple edges between the same pair of vertices.

Given the structure defined by the edges in a graph, many problems can be stated in terms of paths from a source vertex to a destination vertex in the graph constructed using the existing edges in the graph. Sometimes an edge has an associated numeric value known as its weight; sometimes an edge is directed with a specific orientation (like a one-way street). In the Single-Source Shortest Path algorithm, one is given a specific vertex, s, and asked to compute the shortest path (by sum of edge weights) to all other vertices in the graph. The All-Pairs Shortest Path problem requires that the shortest path be computed for all pairs (u, v) of vertices in the graph.

Some problems seek a deeper understanding of the underlying graph structure. For example, the minimum spanning tree (MST) of an undirected, weighted ...

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

Algorithms, 4th Edition

Algorithms, 4th Edition

Robert Sedgewick, Kevin Wayne
Learning Algorithms

Learning Algorithms

George Heineman
Dive Into Algorithms

Dive Into Algorithms

Bradford Tuckfield
Algorithms in a Nutshell

Algorithms in a Nutshell

George T. Heineman, Gary Pollice, Stanley Selkow

Publisher Resources

ISBN: 9781491912973Errata Page