Working with shared memory and printing graph