Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C++ Data Structures and Algorithm Design Principles

You're reading from   C++ Data Structures and Algorithm Design Principles Leverage the power of modern C++ to build robust and scalable applications

Arrow left icon
Product type Paperback
Published in Oct 2019
Publisher
ISBN-13 9781838828844
Length 626 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (4):
Arrow left icon
Anil Achary Anil Achary
Author Profile Icon Anil Achary
Anil Achary
John Carey John Carey
Author Profile Icon John Carey
John Carey
Payas Rajan Payas Rajan
Author Profile Icon Payas Rajan
Payas Rajan
Shreyans Doshi Shreyans Doshi
Author Profile Icon Shreyans Doshi
Shreyans Doshi
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

About the Book 1. Lists, Stacks, and Queues 2. Trees, Heaps, and Graphs FREE CHAPTER 3. Hash Tables and Bloom Filters 4. Divide and Conquer 5. Greedy Algorithms 6. Graph Algorithms I 7. Graph Algorithms II 8. Dynamic Programming I 9. Dynamic Programming II 1. Appendix

The Graph Traversal Problem

Imagine that you have recently moved into an apartment in a new neighborhood. As you meet your new neighbors and make new friends, people often recommend restaurants to dine at in the vicinity. You wish to visit all the recommended restaurants, so you pull out a map of the neighborhood and mark all the restaurants and your home on the map, which already has all the roads marked on it. If we represent each restaurant and your home as a vertex, and the roads connecting the restaurants as edges in a graph, the problem of visiting all the vertices in the graph, when starting from a given vertex, is called the graph traversal problem.

In the following figure, the numbers in blue are assumed vertex IDs. Vertex 1 is Home, and the restaurants are labeled from R1 to R7. None of the edges have arrows since the edges are assumed to be bidirectional, that is, you can travel on the roads in either direction:

Figure 6.2: Representing a neighborhood map as a graph
Figure 6.2: Representing a neighborhood map as...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image