Course Content
Breadth First Search
Breadth First Search
1. What is BFS
3. Improve Your Code
4. Solving the Problems using BFS
Graph Class Implementation
In this course, weβll use Graph
implementation as class:
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
This works for oriented graph. Main methods are implemented, and youβll add some methods according to the next tasks.
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 2
Graph Class Implementation
In this course, weβll use Graph
implementation as class:
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
This works for oriented graph. Main methods are implemented, and youβll add some methods according to the next tasks.
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 2