-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteste_function_maior_seq.cpp
More file actions
60 lines (55 loc) · 2.02 KB
/
Copy pathteste_function_maior_seq.cpp
File metadata and controls
60 lines (55 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// #include <iostream>
// #include <limits.h>
// #include <vector>
// #include <functional>
// #include <algorithm>
// #include <queue>
// #include <vector>
// #include "graphadj.h"
// using namespace std;
// void CaminhoLimitado(GraphAdjList* G, int parents[],int distances[],int tempo[],int fonte,int sorvedouro,int t){
// // Inicializa os vetores de distancias, pais e checked
// bool checked[G->getNumVertex()];
// for (int i = 0; i < G->getNumVertex(); i++){
// distances[i] = INT_MAX;
// parents[i] = -1;
// checked[i] = false;
// tempo[i] = INT_MAX;
// }
// // Define a distancia da fonte para ela mesma como 0
// parents[fonte] = fonte;
// distances[fonte] = 0;
// tempo[fonte] = 0;
// // Adiciona a fonte na heap
// priority_queue<PII, vector<PII>, greater<PII>> heap;
// heap.push({0, fonte});
// // Enquanto a heap nao estiver vazia
// while (!heap.empty()){
// // Pega o primeiro elemento da fila de prioridade, aquele com menor distancia
// int v1 = heap.top().second;
// heap.pop();
// // Se o vértice já foi verificado, ignore
// if (checked[v1])
// continue;
// // Marca o vértice como verificado
// checked[v1] = true;
// // Percorre os vértices adjacentes ao vértice atual
// EdgeNode* edge = G->edges[v1]->getNext();
// while (edge != nullptr){
// int v2 = edge->getVertex();
// int tamanho = edge->iWeight;
// int tempoV2 = edge->iTempo;
// // Cria a árvore considerando a menor distância e o limite de tempo
// if(tempo[v1] + tempoV2 <= t && distances[v1] + tamanho < distances[v2]){
// distances[v2] = distances[v1] + tamanho;
// tempo[v2] = tempo[v1] + tempoV2;
// parents[v2] = v1;
// heap.push({distances[v2], v2});
// }
// node = node->next;
// }
// }
// }
// int main(){
// return 0;
// }