If solution is thought of as symmetric matrix with all-unique elements (i.e. "edge labels") per row (and therefore, per column) and crossed-out dummy diagonal, then quite formal algorithm to build it could be as follows. Code is not pretty, at least I hope I streamlined it enough after couple of, even uglier, attempts.

use strict; use warnings; use feature 'say'; use constant LETTERS => join '', 'A'..'Z', 'a'..'z'; # template use constant N => 51; # number of "e +dges" die if not N % 2 # (1) prohibit odd nodes number or N > 51; # (2) "template" limitation say '_' . substr LETTERS, 0, N; my $last = substr LETTERS, N - 1, 1; # "collect" last line here for ( 1 .. N - 1 ) { my $s = substr LETTERS, 0, N; my $sfx = substr $s, 0, $_ - 1, ''; $s .= $sfx; # rotate left $sfx = substr $s, $_, 1, '_'; $s .= $sfx; # ...& append replaced diagona +l item say $s; $last .= substr $s, -1; } say $last . '_'; __END__

Extended 2:53 2/20/22: now here's formal generation code for both odd/even number of "edges", at expense of introducing additional "edge label" (a star) in latter case:

use strict; use warnings; use feature 'say'; use constant LETTERS => join '', 'A'..'Z', 'a'..'z'; use constant N => 12; say '_' . substr LETTERS, 0, N; my $last = substr LETTERS, N - 1, 1; for ( 1 .. N - 1 ) { my $s = substr LETTERS, 0, N; my $sfx = substr $s, 0, $_ - 1, ''; $s .= '*' unless N % 2; $s .= $sfx; $sfx = substr $s, $_, 1, '_'; $s .= $sfx if N % 2; say $s; $last .= substr $s, -1; } say $last . '_'; __END__ _ABCDEFGHIJKL A_CDEFGHIJKL* BC_EFGHIJKL*A CDE_GHIJKL*AB DEFG_IJKL*ABC EFGHI_KL*ABCD FGHIJK_*ABCDE GHIJKL*_BCDEF HIJKL*AB_DEFG IJKL*ABCD_FGH JKL*ABCDEF_HI KL*ABCDEFGH_J L*ABCDEFGHIJ_

In reply to Re: Graph labeling problem by vr
in thread Graph labeling problem by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.