moved structure graph code into own file