read and write graphs to disk in streams