Академический Документы
Профессиональный Документы
Культура Документы
MOLDOVA
Universitatea Tehnică a Moldovei
Facultatea Calculatoare, Informatică şi Microelectronică
Departamentul Inginerie Software și Automatică
RAPORT
Lucrare de laborator nr. 6
la cursul „Matematica discretă”
Tema: «Разработка программы на C++ для нахождения
остовного графа»
#include <iostream>
#include <vector>
vector<vector<int>> tree(n);
for (int i = 0; i < n; i++) {
if (parent[i] != -1) {
tree[parent[i]].push_back(i);
tree[i].push_back(parent[i]);
}
}
return tree;
}
int main() {
int n, m;
cout << "Enter the number of vertices: ";
cin >> n;
vector<vector<int>> graph;
switch (type) {
case 1:
cout << "Enter the number of edges: ";
cin >> m;
graph = input_incidence_matrix(n, m);
break;
case 2:
graph = input_adjacency_matrix(n);
break;
case 3:
graph = input_adjacency_list(n);
break;
default:
cout << "Invalid input type" << endl;
return 0;
}
return 0;
}
/*
Матрица инцидентности:
Матрица смежности:
Enter the number of vertices: 4
Enter the adjacency matrix:
0 1 1 0
1 0 1 1
1 1 0 1
0 1 1 0
Enter the starting vertex: 2
Список смежности:
Enter the number of vertices: 6
Enter the adjacency list:
0 1 3
1 0 2 3
2 1 3 4
3 0 1 2 5
4 2 5
5 3 4
Enter the starting vertex: 4
*/