Representing Graphs

Preview:

DESCRIPTION

Graph Algorithms. Representing Graphs. Design and Analysis of Algorithms I. Graphs. Consider an undirected graph that has vertices, no parallel edges, and is connected (i.e., “in one piece”). What is the minimum and maximum number of edges that the graph could have, respectively?. and . - PowerPoint PPT Presentation

Citation preview

Graph AlgorithmsRepresenting Graphs

Design and Analysis of Algorithms I

Tim Roughgarden

Graphs

and

𝑛−1  and  𝑛2

𝑛   and  2𝑛

𝑛   and  𝑛𝑛

Consider an undirected graph that has vertices, no parallel edges, and is connected (i.e., “in one piece”). What is the minimum and maximum number of edges that the graph could have, respectively?

Tim Roughgarden

Sparse vs. Dense Graphs

Tim Roughgarden

The Adjacency Matrix

𝜃(𝑛)𝜃(𝑚)𝜃(𝑚+𝑛)𝜃(𝑛2)

How much space does an adjacency matrix require, as a function of the number of vertices and the number of edges?

Tim Roughgarden

Adjacency Lists

𝜃(𝑛)𝜃(𝑚)𝜃(𝑚+𝑛)𝜃(𝑛2)

How much space does an adjacency list representation require, as a function of the number of vertices and the number of edges?

Tim Roughgarden

Adjacency Lists

Recommended