The problem should with these two lines in the insert function:
*newEdge->vertex1 = v1;
*newEdge->vertex2 = v2;
vertex1
and vertex2
are uninitialized pointers, they are not pointing to valid locations in the memory and you are trying to write to those locations. I suspect you want vertex1
and vertex2
to simply be ints that hold vertex IDs.
A similarly write is attempted by your remove function. You should fix that too.