  Etzion et al. introduced metrics on $\mathbb{F}_2^n$ based on directed graphs
on $n$ vertices and developed some basic coding theory on directed graph metric
spaces. In this paper, we consider the problem of classifying directed graphs
which admit the extended Hamming codes to be a perfect code. We first consider
weighted poset metrics as a natural generalization of poset metrics and
investigate interrelation between weighted poset metrics and directed graph
based metrics. In the next, we classify weighted posets on a set with eight
elements and directed graphs on eight vertices which admit the extended Hamming
code $\widetilde{\mathcal{H}}_3$ to be a $2$-perfect code. We also construct
some families of such structures for any $k \geq 3$. Those families enable us
to construct packing or covering codes of radius 2 under certain maps.
