MATLAB: How can it be that expm of a sparse matrix with only 0 and 1 entries produces negative numbers

expm negative entries

I have a sparse square matrix A (an adjacency matrix for a network, 133×133), with only 0 and 1 entries.
When I do Aexpm=expm(A), the resulting Aexpm has negative entries.
The number in the negative entries are very small, of the order of -2.65836297406977e-17, but this is still a problem when I want to operate with Aexpm.
Does anyone know why matlab is giving negative numbers out of expm(A) and any way to solve this?

Best Answer

Round-off error.
Aexpm( abs(Aexpm) < 1e-15) ) = 0;