2023-03-02 18:57:33 +08:00
|
|
|
/**
|
2023-04-24 04:11:18 +08:00
|
|
|
* File: vertex.hpp
|
2023-03-02 18:57:33 +08:00
|
|
|
* Created Time: 2023-03-02
|
2024-02-07 22:21:18 +08:00
|
|
|
* Author: krahets (krahets@163.com)
|
2023-03-02 18:57:33 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
2023-07-19 16:09:27 +08:00
|
|
|
|
2023-03-02 18:57:33 +08:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
/* 顶点类 */
|
|
|
|
struct Vertex {
|
|
|
|
int val;
|
2023-04-14 03:44:02 +08:00
|
|
|
Vertex(int x) : val(x) {
|
|
|
|
}
|
2023-03-02 18:57:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* 输入值列表 vals ,返回顶点列表 vets */
|
2023-04-14 03:44:02 +08:00
|
|
|
vector<Vertex *> valsToVets(vector<int> vals) {
|
|
|
|
vector<Vertex *> vets;
|
2023-03-02 18:57:33 +08:00
|
|
|
for (int val : vals) {
|
|
|
|
vets.push_back(new Vertex(val));
|
|
|
|
}
|
|
|
|
return vets;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 输入顶点列表 vets ,返回值列表 vals */
|
2023-04-14 03:44:02 +08:00
|
|
|
vector<int> vetsToVals(vector<Vertex *> vets) {
|
2023-03-02 18:57:33 +08:00
|
|
|
vector<int> vals;
|
|
|
|
for (Vertex *vet : vets) {
|
|
|
|
vals.push_back(vet->val);
|
|
|
|
}
|
|
|
|
return vals;
|
|
|
|
}
|