Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| courses:cs211:winter2018:journals:thetfordt:chapter3 [2018/02/04 19:16] โ thetfordt | courses:cs211:winter2018:journals:thetfordt:chapter3 [2018/02/05 19:37] (current) โ thetfordt | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| The section then goes on to illustrate a few different ways to generate the connected component - the first being the breadth-first search (BFS). The | The section then goes on to illustrate a few different ways to generate the connected component - the first being the breadth-first search (BFS). The | ||
| - | BFS starts at a node, call it ' | + | BFS starts at a node, call it ' |
| The section then moves on to the concept of exploring a connected component. It lays forth an algorithm to seek out the connected component in a vague manner. It just continually adds nodes to a set R which are connected to nodes in the component, R, until it cannot any longer. The set R begins as just the start node, ' | The section then moves on to the concept of exploring a connected component. It lays forth an algorithm to seek out the connected component in a vague manner. It just continually adds nodes to a set R which are connected to nodes in the component, R, until it cannot any longer. The set R begins as just the start node, ' | ||
| Line 25: | Line 25: | ||
| ===== Section 3.3 - Implementing Graph Traversal Using Queues and Stacks ===== | ===== Section 3.3 - Implementing Graph Traversal Using Queues and Stacks ===== | ||
| - | The section begins by providing a short summary of what will be covered. We will walk through the different ways for implementing graphs, and then the same concept, but with the implementation of graph-traversal algorithms. | + | The section begins by providing a short summary of what will be covered. We will walk through the different ways of implementing graphs, and then the same concept, but with the implementation of graph-traversal algorithms. |
| The section then outlines the two ways of representing a graph, an adjacency matrix and an adjacency list. And although the adjacency matrix maintains constant access runtime to access a particular connection between two nodes. The book also walks through the proof that the adjacency list takes only O(m+n) space whereas the matrix takes O(n^2) space. I found this proof very helpful, as I was a bit hazy on using two separate variables after covering it in class. Because of this improved space (as m is always less than or equal to n^2), the book uses the adjacency lists for further implementation. | The section then outlines the two ways of representing a graph, an adjacency matrix and an adjacency list. And although the adjacency matrix maintains constant access runtime to access a particular connection between two nodes. The book also walks through the proof that the adjacency list takes only O(m+n) space whereas the matrix takes O(n^2) space. I found this proof very helpful, as I was a bit hazy on using two separate variables after covering it in class. Because of this improved space (as m is always less than or equal to n^2), the book uses the adjacency lists for further implementation. | ||
| Line 32: | Line 32: | ||
| The section then walks through the implementation of the depth-first search (DFS). This algorithm uses a stack for implementation. It initializes S to be a stack with one element, the start node ' | The section then walks through the implementation of the depth-first search (DFS). This algorithm uses a stack for implementation. It initializes S to be a stack with one element, the start node ' | ||
| + | |||
| + | I found this section to be helpful, but a bit dense. I understood most of these concepts from class, so it was primarily review. I would rate the readability at 7/10. | ||
| ===== Section 3.4 - Testing Bipartiteness: | ===== Section 3.4 - Testing Bipartiteness: | ||
| + | |||
| + | This section walks through an application of the Breadth-First Search. The problem we encounter is that we want an efficient way of determining if a graph is bipartite. The section first reasons clearly through the fact that if a graph is bipartite, then it cannot contain an odd-length cycle. | ||
| + | |||
| + | The section then designs an algorithm for determining if a graph is bipartite. It assumes first that a graph is connected. We pick any node to start with, color it red, perform a breadth-first search, alternating the colors of each layer. And if at any point, there is some edge with ends of the same color, we know that the graph is not bipartite. Otherwise, every edge has opposite colors on it and thus is bipartite. | ||
| + | |||
| + | The section then analyzes the algorithm, claiming that either (1) there is no edge of G joining two nodes of the same layer - and here G is bipartite. Otherwise, there is an edge of G joining two nodes of the same layer. And here, G contains an odd-length cycle and thus is not bipartite. This proof was very clear and cleared up some confusion I had at the last class, as we were cut short while going over the logic behind this claim. | ||
| + | |||
| + | This section was short and easy to read, I would rate the readability at 9/10. | ||
| + | |||
| + | ===== Section 3.5 - Connectivity in Directed Graphs ===== | ||
| + | |||
| + | In this section, we move away from undirected graphs into the territory of directed graphs. The book first walks through the primary way of representing directed graphs. We will do this using two adjacency lists of the nodes, one containing the " | ||
| + | |||
| + | The text walks through the idea of strong connectivity, | ||
| + | |||
| + | This section was a nice review, and short. I would rate the readability at 8/10. | ||
| + | ===== Section 3.6 - Directed Acyclic Graphs and Topological Ordering ===== | ||
| + | |||
| + | This section begins by walking through some ideas surrounding directed versus undirected graphs and then defines what a graph with no cycles is called - a directed acyclic graph, or DAG. | ||
| + | |||
| + | The book walks simply through the proof that if a graph G has a topological ordering, then G is a DAG, but then proposes the question as to whether there is an implication that G has a topological ordering if G is a DAG. When walking through the proof of this, I understood it more clearly from class. In class, I did not make the connection that we could continue walking backward through the graph indefinitely. | ||
| + | |||
| + | The book then walks through the algorithm to organize a DAG in a topological order. The algorithm first targets a node with no incoming edges, deletes that node from the graph, and then recursively computes a topological ordering of the graph minus that first node. This algorithm appears to run in O(n^2) time, but in actuality, if we keep track of the number of incoming edges that each node has whenever we delete a node, the runtime is O(n+m). This concept was a bit hazy in class, but made more sense after reading the chapter. | ||
| + | |||
| + | I would rate the readability of this section at 9/10. It was easy to follow and cleared up some confusing concepts. | ||
| + | |||
| + | |||
