We introduce a generalized adjacency matrix in order to distinguish cospectral graphs. Our reasoning is motivated by the work of Johnson and Newman and properties of p-adic numbers. Using a polynomial time algorithm, we comment on computer experiments with which we can distinguish cospectral (non-isomorphic) graphs.