-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
39 lines (31 loc) · 1.04 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// test 8: tests copy construction
#include "Graph.hpp"
int main() {
auto gHeap = new cs6771::Graph<std::string,int>{};
// add this data into the graph
gHeap->addNode("a");
gHeap->addNode("b");
gHeap->addNode("c");
gHeap->addNode("d");
gHeap->addEdge("b","a",3);
gHeap->addEdge("b","a",5);
gHeap->addEdge("c","a",3);
std::cout << "original graph" << std::endl;
gHeap->printNodes();
gHeap->printEdges("b");
cs6771::Graph<std::string,int> gHeapCopy;
gHeapCopy.addNode("z");
std::cout << "Graph before copy assignment" << std::endl;
gHeapCopy.printNodes();
gHeapCopy = *gHeap; // copy assignment
gHeap->deleteNode("a");
std::cout << "original graph after delete" << std::endl;
gHeap->printNodes();
gHeap->printEdges("b");
std::cout << "copied graph after delete in other graph" << std::endl;
gHeapCopy.printNodes();
gHeapCopy.printEdges("b");
delete gHeap;
std::cout << "copied graph after other graph is deleted" << std::endl;
gHeapCopy.printNodes();
}