Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
courses:cs211:winter2014:journals:colin:chapter3 [2014/02/02 21:20] – mohnacsc | courses:cs211:winter2014:journals:colin:chapter3 [2014/02/02 23:55] (current) – mohnacsc | ||
---|---|---|---|
Line 55: | Line 55: | ||
The DFS algorithm visits each node using a reverse adjacency list. It runs in time O(m+n) if the graph is given by the adjacency list representation. | The DFS algorithm visits each node using a reverse adjacency list. It runs in time O(m+n) if the graph is given by the adjacency list representation. | ||
+ | |||
+ | |||
+ | === Discussion === | ||
+ | |||
+ | The breadth-first and depth-first search algorithms are pretty straight forward and have predictable run times. | ||
+ | |||
+ | |||
+ | ==== 3.4 - Testing Bipartiteness: | ||
+ | |||
+ | A bipartite graph is one where the node set V can be partitioned into sets X and Y in such a way that every edge has one end in X and the other end in Y. If a graph is bipartite, then it cannot contain an odd cycle. | ||
+ | |||
+ | We can test a graph for bipartiteness by choosing some node s and coloring it red. The neighbors of s must be colored blue and, in turn, we must make the neighbors of blue nodes red. We continue this process until we have visited every node, similar to the BFS algorithm. | ||
+ | |||
+ | Let G be a connected graph. | ||
+ | * There is no edge of G joining two nodes of the same layer. | ||
+ | * There is an edge of G joining two nodes of the same layer. | ||
+ | |||
+ | |||
+ | ==== 3.5 - Connectivity in Directed Graphs ==== | ||
+ | |||
+ | A directed graph in adjacency list representation has two associated lists for each node: nodes to which it has edges and nodes from which it has edges. | ||
+ | |||
+ | |||
+ | ==== 3.6 - Directed Acyclic Graphs and Topological Ordering ==== | ||
+ | |||
+ | If a directed graph has no cycles it is a directed acyclic graph (DAG). | ||
+ | |||
+ | In every DAG G, there is a node v with no incoming edges. | ||
+ | |||
+ | |||
+ | === Discussion === | ||
+ | |||
+ | With the expansion of the BFS and DFS applications, |