Skip to content

Commit

Permalink
lab 4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-anastasiia committed Nov 25, 2024
1 parent 47abe53 commit 5705d14
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions LibraryCPPTemplate/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,26 @@ class Graph {

Edge*& exists_edge = edgeMatrix[startIv * qty_vertex + endIv];

if (exists_edge == nullptr) {
exists_edge = new Edge(edge_data);
}
else {
exists_edge->set_EdgeData(edge_data);
/
if (exists_edge != nullptr) {
delete exists_edge;
}

exists_edge = new Edge(edge_data);

if (type == GraphType::Undirected) {
Edge*& exists_ReverseEdge = edgeMatrix[endIv * qty_vertex + startIv];
if (exists_ReverseEdge == nullptr) {
exists_ReverseEdge = new Edge(edge_data);
}
else {
exists_ReverseEdge->set_EdgeData(edge_data);

if (exists_ReverseEdge != nullptr) {
delete exists_ReverseEdge;
}

exists_ReverseEdge = new Edge(edge_data);
}
}



void remove_Edge(size_t startIv, size_t endIv) {
if (startIv >= get_VertexAmount() || endIv>= get_VertexAmount()) {
throw std::out_of_range("Vertex index out of range.");
Expand Down

0 comments on commit 5705d14

Please sign in to comment.