  The radial distribution of $D^0$ mesons in jets probes the diffusion of charm
quark relative to the jet axis and provides a new perspective to study the
interaction mechanisms between heavy quarks and the medium in the
nucleus-nucleus collisions. The in-medium parton propagations are described by
a Monte Carlo transport model which uses the next-to-leading order (NLO) plus
parton shower (PS) event generator SHERPA as input and includes elastic
(collisional) and inelastic (radiative) interaction for heavy quarks as well as
light partons. At low $D^0$ meson $p_T$, the radial distribution significantly
shifts to larger radius indicating a strong diffusion effect which is
consistent with the recent experimental data. We demonstrate that the angular
deviation of charm quarks declines with $p_T$ and is very sensitive to the
collisional more than radiative interaction at $p_T<5$~GeV. As predictions, we
present the $D^0$ meson radial distribution in jets in p+p and $0-10\%$ Au+Au
collisions at $\sqrt{s_{NN}}=200$~GeV at the RHIC, and also estimate the
nuclear modification factor of charm jet in central Au+Au collisions at 200~GeV
at the RHIC and central Pb+Pb collisions at $5.02$~TeV at the LHC.
