in reply to creating adjacency matrix

Like this?

#! perl -slw use strict; use Data::Dump qw[ pp ]; sub uniq{ my %h; undef @h{ @_ }; keys %h }; my @pairs = map[ split ], split ', ', 'A B, B C, C D';; my @uniq = uniq( map @$_, @pairs ); my %mat; @{ $mat{ $_ } }{ @uniq } = (0) x @uniq for @uniq; $mat{ $_->[0] }{ $_->[1] } = $mat{ $_->[1] }{ $_->[0] } = 1 for @pairs; pp \%mat; __END__ c:\test>880739 { A => { A => 0, B => 1, C => 0, D => 0 }, B => { A => 1, B => 0, C => 1, D => 0 }, C => { A => 0, B => 1, C => 0, D => 1 }, D => { A => 0, B => 0, C => 1, D => 0 }, }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.