graph1
itself is an unitialized pointer. So, calling it's members is causing the program to crash. Initialize it with new
operator.
graph1 = new Graph();
// .......
delete graph1;
Or use a smart pointer like std::unique_ptr
to automatically manage memory.