bug:connect函数在处理插入已存在连接时的业务逻辑错误
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by 31416 on 24-12-5.
|
||||
//
|
||||
|
||||
#ifndef MATRIXGRAPH_H
|
||||
#define MATRIXGRAPH_H
|
||||
|
||||
#include<vector>
|
||||
using namespace std;
|
||||
|
||||
template<typename T>
|
||||
class MatrixGraph {
|
||||
private:
|
||||
vector<T> data;
|
||||
vector<vector<bool> > matrix;
|
||||
int nodeCount;
|
||||
public:
|
||||
MatrixGraph() {
|
||||
matrix.clear();
|
||||
data.clear();
|
||||
nodeCount = 0;
|
||||
}
|
||||
void insert(T value) {
|
||||
data.push_back(value);
|
||||
nodeCount++;
|
||||
matrix.push_back(vector<bool>(nodeCount, false));
|
||||
for(int i = 0; i < nodeCount-1; ++i) {
|
||||
matrix[i].push_back(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //MATRIXGRAPH_H
|
||||
Reference in New Issue
Block a user