Слайд 2
![Definition G = (V, E) V – vertexes E – edges](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-1.jpg)
Definition
G = (V, E)
V – vertexes
E – edges
Слайд 3
![Types Directed/undirected Weighted/unweighted Simple graph/multigraph Connected/unconnected Bipartite With cycles/without cycles](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-2.jpg)
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)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-3.jpg)
Ways of presenting in memory
Adjacency matrix
Memory: O(|V|^2)
Слайд 5
![Ways of presenting in memory Incidence matrix Memory: O(|V|*|E|)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-4.jpg)
Ways of presenting in memory
Incidence matrix
Memory: O(|V|*|E|)
Слайд 6
![Ways of presenting in memory List of edges Memory: O(|E|)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-5.jpg)
Ways of presenting in memory
List of edges
Memory: O(|E|)
Слайд 7
![Ways of presenting in memory Adjacency list Memory: O(|E|)](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-6.jpg)
Ways of presenting in memory
Adjacency list
Memory: O(|E|)
Слайд 8
![Problems without explicit graph Labyrinth Number of objects](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-7.jpg)
Problems without explicit graph
Labyrinth
Number of objects
Слайд 9
![Basic algorithms Depth-First Search (DFS) void dfs(int u) { if](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-8.jpg)
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](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-9.jpg)
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](/_ipx/f_webp&q_80&fit_contain&s_1440x1080/imagesDir/jpg/96389/slide-10.jpg)
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