Chapter 6. Graph Algorithms
How does immutability affect algorithm design? How are typical algorithms implemented without resorting to in-place mutation?
This chapter will give you a taste of functional algorithms. List prepending will be one dominating theme here. We will start by looking at list reversal and how prepending helps in dealing with algorithms.. We will then look at an efficient algorithm for list reversal using list prepending.
Graphs are a very important data structure; they are used to model related entities. We will be looking at directed graphs, also known as digraphs. We will implement functional versions of common digraph algorithms, for example, traversing a graph and visiting each node to do something useful.
Topological sorting is a digraph algorithm used to compute nodes' order of precedence. Build tools, such as Make, need to order tasks based on precedence. Topological sorting is the algorithm used by such tools to process a task's dependencies...