Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| courses:cs211:winter2018:journals:shermanc:chapter3 [2018/02/06 05:17] – shermanc | courses:cs211:winter2018:journals:shermanc:chapter3 [2018/02/07 04:26] (current) – [3.6: Directed Acyclic Graphs and Topological Ordering] shermanc | ||
|---|---|---|---|
| Line 68: | Line 68: | ||
| ===== 3.5: Connectivity in Directed Graphs ===== | ===== 3.5: Connectivity in Directed Graphs ===== | ||
| + | This section started off by talking about how to represent directed graphs in algorithms, which is by using a version of the adjacency list. In this, each individual node will have a list for the nodes that it has edges and a list for the nodes of which it has edges from. | ||
| + | The interesting part here that I have some questions about was how a directed graph-version of BFS computes a path from //s// to //t//, just as the undirected version, but in this version t does not necessarily have a path back to // | ||
| + | DFS also runs naturally on a directed graph and both algorithms keep their respective run times of O(m + n) and O(m). | ||
| + | |||
| + | If we want to find the paths to //s// instead of from, we can simply run B or DFS on G< | ||
| + | |||
| + | To find if a directed graph is strongly connected, we can run an algorithm where we start at any node in the graph and run BFS from that node, then run BFS on the same node but in G< | ||
| + | |||
| + | The last topic in this chapter, __strong components__, | ||
| + | |||
| + | |||
| + | ===== 3.6: Directed Acyclic Graphs and Topological Ordering ===== | ||
| + | |||
| + | This section started off with a bang: an undirected graph with no cycles, it is just a tree. __**// | ||
| + | |||
| + | A simple way to think about DAGs is as if we have a set of classes the have prerequisites, | ||
| + | |||
| + | It actually goes to get proven that the converse is indeed true as well, where if G is a DAG, then G has a topological ordering. | ||
| + | |||
| + | This section was a more in-depth (first search; forgive the pun) than preceding sections, as was the last one. A question I still have that I have meant to pose over this chapter: why is O(m + n) have m listed first? | ||
