File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -141,8 +141,9 @@ int main() {
141
141
}
142
142
143
143
// ////////Vertex removal check//////////////////////////////////////////
144
- /* graph.add_Edge(2, 3, 5);
145
- graph.add_Edge(0, 4, 1);*/
144
+ graph.add_Edge (0 , 1 , 10 );
145
+ graph.add_Edge (2 , 3 , 5 );
146
+ graph.add_Edge (0 , 4 , 1 );
146
147
147
148
int index1 = 3 ;
148
149
std::cout << " Deleting a vertex with an index: " << index1 << std::endl;
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ class Graph {
24
24
}
25
25
26
26
~Graph () {
27
- for (size_t i = 0 ; i < edgeMatrix.size (); ++i) {
28
- delete edgeMatrix[i];
29
- edgeMatrix[i] = nullptr ;
27
+ size_t qty_vertex = get_VertexAmount ();
28
+ for (size_t i = 0 ; i < qty_vertex; ++i) {
29
+ for (size_t j = 0 ; j < qty_vertex; ++j) {
30
+ delete edgeMatrix[i * qty_vertex + j];
31
+ edgeMatrix[i * qty_vertex + j] = nullptr ;
32
+ }
30
33
}
31
34
}
32
35
36
+
33
37
Graph (const Graph& a) : type(a.type), vertices(a.vertices) {
34
38
edgeMatrix.resize (a.edgeMatrix .size ());
35
39
for (size_t i = 0 ; i < a.edgeMatrix .size (); ++i) {
You can’t perform that action at this time.
0 commit comments