correct graph with matrix implementation.