0

I'm comparing graph traversal material between two books: CLRS's Introduction to Algorithms, 3rd Edition (known simply as CLRS), and RN's Artificial Intelligence: A Modern Approach, 3rd edition (known simply as AIMA).

In both the sections on Breadth First Search and Depth First Search I notice that CLRS keeps track of unvisited nodes, frontier nodes, and visited nodes by coloring them white, gray and black, respectively, meanwhile AIMA keeps track of unvisited, frontier, and visited nodes by keeping track of frontier and visited nodes with data structures external to the graph and its nodes.

It seems the method in AIMA of using data structures to keep track of frontier and visited nodes is more memory efficient and works better in the case that there may be infinite nodes in the graph. Is there a reason someone would prefer graph coloring instead, or what are the differences between the two?

1 Answers1

0

In writing the question I understood the answer: there are a few differences.

  1. CLRS is dealing with finite graphs in these sections, whereas AIMA from the start is dealing with graphs of unknown and possibly unbounded size. The first step in CLRS's search algorithms is to color every graph node white, so this isn't applicable to AIMA's case.

  2. In AIMA, as mentioned before, the graph should not be traversed in its entirety as CLRS is doing because, at least in part, of its possibly large or unbounded size. Therefore when a node is first discovered in AIMA's graph search it is immediately placed in the frontier and therefore a white coloring would serve no purpose, every node discovered is either on the frontier or visited, so that a three color scheme does not make sense in that case.

  3. These graph searches' use-cases are different. In AIMA graph search is used to find a sequence of actions that leads to a solution goal state of a problem. In CLRS traversing the nodes is a way to learn properties of the entire graph. See for example: https://stackoverflow.com/a/38936312/5834035

Community
  • 1
  • 1