Graphs - 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

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 depth-first 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 node-node 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 node-edge 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 node-node adjacency structure is 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 The node-edge 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) Depth-first search (DFS) can be used to solved all three problems. It is usually assumed that the graph data structure is of the type node-edge adjacency instead of node-node adjacency. In the node-edge 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.

Page1 / 4

Graphs - 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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online