Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Graph Class Implementation | What is BFS
Breadth First Search
course content

Зміст курсу

Breadth First Search

Breadth First Search

1. What is BFS
2. Practice
3. Improve Your Code
4. Solving the Problems using BFS

Graph Class Implementation

In this course, we’ll use Graph implementation as class:

1234567891011121314
class Graph: def __init__(self, vertices): # init graph with its vertices self.graph = {v : [] for v in vertices} def addEdge(self, u, v): self.graph[u].append(v) def __str__(self): out = "" for vertex in self.graph: out += vertex + ":"+self.graph[vertex] return out
copy

This works for oriented graph. Main methods are implemented, and you’ll add some methods according to the next tasks.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 1. Розділ 2
toggle bottom row

Graph Class Implementation

In this course, we’ll use Graph implementation as class:

1234567891011121314
class Graph: def __init__(self, vertices): # init graph with its vertices self.graph = {v : [] for v in vertices} def addEdge(self, u, v): self.graph[u].append(v) def __str__(self): out = "" for vertex in self.graph: out += vertex + ":"+self.graph[vertex] return out
copy

This works for oriented graph. Main methods are implemented, and you’ll add some methods according to the next tasks.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 1. Розділ 2
toggle bottom row

Graph Class Implementation

In this course, we’ll use Graph implementation as class:

1234567891011121314
class Graph: def __init__(self, vertices): # init graph with its vertices self.graph = {v : [] for v in vertices} def addEdge(self, u, v): self.graph[u].append(v) def __str__(self): out = "" for vertex in self.graph: out += vertex + ":"+self.graph[vertex] return out
copy

This works for oriented graph. Main methods are implemented, and you’ll add some methods according to the next tasks.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

In this course, we’ll use Graph implementation as class:

1234567891011121314
class Graph: def __init__(self, vertices): # init graph with its vertices self.graph = {v : [] for v in vertices} def addEdge(self, u, v): self.graph[u].append(v) def __str__(self): out = "" for vertex in self.graph: out += vertex + ":"+self.graph[vertex] return out
copy

This works for oriented graph. Main methods are implemented, and you’ll add some methods according to the next tasks.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 1. Розділ 2
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt