Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Preparation | Greedy on Graphs
Greedy Algorithms using Python
course content

Conteúdo do Curso

Greedy Algorithms using Python

Greedy Algorithms using Python

1. Greedy Algorithms: Overview and Examples
2. Greedy on Arrays
3. Greedy on Graphs

bookPreparation

This chapter is dedicated to different approaches to find minimum-weighted paths on graphs. We work with oriented weighted graphs here.

To solve problems, we’ll use a pre-implemented class Graph defined with an adjacency matrix, since each edge has some weight that will be stored in the matrix.

1234567891011121314151617
class Graph: def __init__(self, vertices=0): # init graph with this number of vertices self.g = [[0 for _ in range(vertices)] for _ in range(vertices)] def addEdge(self, u, v, w, o = False): # u - start vertex, v - end vertex, w - weight of edge, o - is it oriented self.g[u][v] = w if not o: self.g[v][u] = w def __str__(self): out = "" for row in self.g: out += str(row) + ' ' return out
copy

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 1
toggle bottom row

bookPreparation

This chapter is dedicated to different approaches to find minimum-weighted paths on graphs. We work with oriented weighted graphs here.

To solve problems, we’ll use a pre-implemented class Graph defined with an adjacency matrix, since each edge has some weight that will be stored in the matrix.

1234567891011121314151617
class Graph: def __init__(self, vertices=0): # init graph with this number of vertices self.g = [[0 for _ in range(vertices)] for _ in range(vertices)] def addEdge(self, u, v, w, o = False): # u - start vertex, v - end vertex, w - weight of edge, o - is it oriented self.g[u][v] = w if not o: self.g[v][u] = w def __str__(self): out = "" for row in self.g: out += str(row) + ' ' return out
copy

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 1
toggle bottom row

bookPreparation

This chapter is dedicated to different approaches to find minimum-weighted paths on graphs. We work with oriented weighted graphs here.

To solve problems, we’ll use a pre-implemented class Graph defined with an adjacency matrix, since each edge has some weight that will be stored in the matrix.

1234567891011121314151617
class Graph: def __init__(self, vertices=0): # init graph with this number of vertices self.g = [[0 for _ in range(vertices)] for _ in range(vertices)] def addEdge(self, u, v, w, o = False): # u - start vertex, v - end vertex, w - weight of edge, o - is it oriented self.g[u][v] = w if not o: self.g[v][u] = w def __str__(self): out = "" for row in self.g: out += str(row) + ' ' return out
copy

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

This chapter is dedicated to different approaches to find minimum-weighted paths on graphs. We work with oriented weighted graphs here.

To solve problems, we’ll use a pre-implemented class Graph defined with an adjacency matrix, since each edge has some weight that will be stored in the matrix.

1234567891011121314151617
class Graph: def __init__(self, vertices=0): # init graph with this number of vertices self.g = [[0 for _ in range(vertices)] for _ in range(vertices)] def addEdge(self, u, v, w, o = False): # u - start vertex, v - end vertex, w - weight of edge, o - is it oriented self.g[u][v] = w if not o: self.g[v][u] = w def __str__(self): out = "" for row in self.g: out += str(row) + ' ' return out
copy

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 1
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
some-alt