Introduction to graphs презентация

Слайд 2

Definition G = (V, E) V – vertexes E – edges

Definition

G = (V, E)
V – vertexes
E – edges

Слайд 3

Types Directed/undirected Weighted/unweighted Simple graph/multigraph Connected/unconnected Bipartite With cycles/without cycles

Types

Directed/undirected
Weighted/unweighted
Simple graph/multigraph
Connected/unconnected
Bipartite
With cycles/without cycles

Слайд 4

Ways of presenting in memory Adjacency matrix Memory: O(|V|^2)

Ways of presenting in memory Adjacency matrix

Memory: O(|V|^2)

Слайд 5

Ways of presenting in memory Incidence matrix Memory: O(|V|*|E|)

Ways of presenting in memory Incidence matrix

Memory: O(|V|*|E|)

Слайд 6

Ways of presenting in memory List of edges Memory: O(|E|)

Ways of presenting in memory List of edges

Memory: O(|E|)

Слайд 7

Ways of presenting in memory Adjacency list Memory: O(|E|)

Ways of presenting in memory Adjacency list

Memory: O(|E|)

Слайд 8

Problems without explicit graph Labyrinth Number of objects

Problems without explicit graph

Labyrinth
Number of objects

Слайд 9

Basic algorithms Depth-First Search (DFS) void dfs(int u) { if

Basic algorithms Depth-First Search (DFS)

void dfs(int u)
{
if (used[u]) return;
used[u] = true;
for (auto

v : g[u])
dfs(v);
}

Complexity: O(|V|+|E|)

Слайд 10

Basic algorithms Breadth-First Search (BFS) void bfs(int s) { queue

Basic algorithms Breadth-First Search (BFS)

void bfs(int s)
{
queue q;
q.push(s);
used[s] = true;
while(!q.empty())
{
int u =

q.front();
q.pop();
for(auto v: g[u])
if(!used[v])
{
q.push(v);
used[v] = true;
}
}
}

Complexity: O(|V|+|E|)

Слайд 11

Examples Find cycle in graph Count number of connected components

Examples

Find cycle in graph
Count number of connected components in graph
Find distance

and path from one vertex to each other in unweighted graph
Имя файла: Introduction-to-graphs.pptx
Количество просмотров: 70
Количество скачиваний: 0