© Elshad Karimov 2020
E. KarimovData Structures and Algorithms in Swifthttps://doi.org/10.1007/978-1-4842-5769-2_16

16. Graph Algorithms

Elshad Karimov1 
New York, New York, USA

It is obvious that the main purpose of many algorithms relates with operations on data, and the data structure plays an important role in choosing an algorithm. In this chapter, we will discuss nonlinear data structures such as graphs.

Graphs are nonlinear data structure which consist of nodes and edges. The basic structure of a graph is shown in Figure 16-1.
Figure 16-1

Graph data structure

In the preceding graph, the set of nodes N = {A,B,D,E,K,J} and the set of edges E = ...

Get Data Structures and Algorithms in Swift: Implement Stacks, Queues, Dictionaries, and Lists in Your Apps now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.