Зміст курсу
Breadth First Search
Breadth First Search
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.
Все було зрозуміло?
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.
Все було зрозуміло?
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.
Все було зрозуміло?
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.