Molecular dynamics (MD) simulations usually analyze the structure of a phase by radial distribution function (RDF), the Honeycutt-Anderson (HA) bond pair analysis, and the cluster-type index method (CTIM). In this paper, we improve CTIM to allow the characterization of more kinds of crystal structure besides bcacc\hcp\non-crystal based on the theory of CTIM. The crystal structures of Zn-Mg alloys have been characterized and the phase distribution of the Zn-Mg diffusion system has been analyzed by CTIM. The results show that the CTIM integers can reveal differences between the Mg21Zn25, MgZn2, and Mg2Zn11 structures, and similarities between the Mg(2)n(7) and MgZn2 structures. Using a two-step simulation on the Zn-Mg diffusion system, fcc and hcp crystals occur at both extremes of the system and there are many non-crystal phases in the middle of the system. In addition, our results show that the interface structure of fcc and hcp crystals on the Zn side is mainly Zn12-C.