This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Cycles in an Undirected Graph 1. Determine if an undirected graph G = ( V , E ) is connected, where  V  = n and  E  = m . 2. Find all the cycles in an undirected graph G . 3. (Optional) Find all articulation points in G . Terminology: Given an undirected graph, a depthfirst search (DFS) algorithm constructs a directed tree from the root (first node in the V ). If there exists a directed path in the tree from v to w , then v is an predecessor of w and w is a descendant of v . A nodenode adjacency structure is an n × n matrix such that entry a ij = 1 if node i is adjacent to node j and 0 otherwise. A nodeedge adjacency structure lists for each node, the nodes adjacent to it. Example Let V = {1,2,3,4} and E = {(1,2), (1,3), (2,3), (3,4)}. The nodenode adjacency structure is 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 The nodeedge adjacency structure is 1: 2,3 2: 1,3 3: 1,2,4 4: 3 1 2 4 3 Note that node 4 is called a leaf . (1 and 2) Depthfirst search (DFS) can be used to solved all three problems. It is usually assumed that the graph data structure is of the type nodeedge adjacency instead of nodenode adjacency. In the nodeedge adjacency structure, the nodes are numbered from 1 to n . The node i record lists the nodes adjacent to node i (connected to node i by an edge). DFS starts by setting node 1 as the current node. DFS iteration ( i is the current node) – If one or more nodes of the node i record were not yet visited from i , let node j be the first node not visited. If node j was already visited by DFS (obviously from node other than node i ), mark edge ( i , j ) as back edge otherwise mark edge ( i , j ) as tree edge and set i as parent of j . Mark node j as visited in the node i record. Set node j as current node....
View
Full
Document
This note was uploaded on 02/14/2012 for the course CSE 109 taught by Professor Michael during the Spring '11 term at UABC MX.
 Spring '11
 michael
 Algorithms

Click to edit the document details