in reply to Re: Graph labeling problem
in thread Graph labeling problem

> I understand "adjacent" as "having a common vertex".

Probably I'm having a fundamental misunderstanding of the problem ...

... but I think with just one more color it's trivial!

Consider an incidence matrix (Node x Node) with the colors given in the cells (here RGBYCM...)

Now a solution for N colors (instead of N-1) is straightforward, we just rotate the N colors left for each row.

NB:

N=3 a b c a R G b R B c G B

N=4 a b c d a R G B b R B Y c G B R d B Y R

N=5 a b c d e a R G B Y b R B Y C c G B C R d B Y C G e Y C R G

N=6 a b c d e f a R G B Y C b R B Y C M c G B C M R d B Y C R G e Y C M R B f C M R G B

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Graph labeling problem
by choroba (Cardinal) on Feb 19, 2022 at 22:06 UTC
    > Probably I'm having a fundamental misunderstanding of the problem ...

    Why? Do you understand "adjacent" in a different way?

    > but I think with one more color it's trivial

    Why "but"? I think so, too.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      > Why? Do you understand "adjacent" in a different way?

      No, in the first draft I thought I could easily improve the solution for the OP's N-1 problem based on this. But then I realized the limitations by symmetry. But I left the phrase in... just in case.

      Anyway - on a meta level - I realized that going for a (slightly) sub-optimal solution is almost ever the clever CS approach.

      Like here, why trying to solve a very hard mathematical problem just to spare one color?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery