Subgraphs q A subgraph S of a graph G is a graph such that n The vertices of S are a subset of the vertices of G n The edges of S are a Subgraph subset of the edges of G q A spanning subgraph of G is a subgraph that contains all the vertices of G
Trees and Forests q A (free) tree is an undirected graph T such that n T is connected n T has no cycles Tree This definition of tree is different from the one of a rooted tree q A forest is an undirected graph without cycles q The connected components of a forest are trees Forest
Analysis of DFS q Setting/getting a vertex/edge label takes O(1) time q Each vertex is labeled twice n once as UNEXPLORED n once as VISITED q Each edge is labeled twice n once as UNEXPLORED n once as DISCOVERY or BACK q Method incidentEdges is called once for each vertex q DFS runs in O(n + m) time provided the graph is represented by the adjacency list structure n Recall that Σv deg(v) = 2m