added serialization to MatrixGraph as it wouldnt be practical to run more than once.