fixed some bugs in graph generator

fixed a bug that caused wierd thread exceptions on some machines(never on my laptop)