simple graph metric matlab code