in reply to creating adjacency matrix

It depends on planned purpose, for instance...

my %adj = (A => ['B'], B => ['A','C'], C => ['B','D'], D =>['C']);