Code cleanups and add WriteRandomGraph example.