baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
i have a math problem that needs to be encoded in perl but i am having trouble figuring out the algorithm
Problem:
let N be a set of vertices (for our purposes let N={1,2,3,4} where numbers are vertex id's) Given any two vertices from N, label the edges so that no two adjacent edges are labelled the same and the number of labels does not exceed |N|-1.
Example:
What would be an algorithm to efficiently identify and label these edges so that the end result is a table of pairs of vertices associated to edge labels:Given a set of the above nodes: 1 2 3 4 The solution would be : b +-----------------+ | c | | +-----------+ + a | b a | 1-----2-----3-----4 | c | +-----------+ where a,b,c are edge labels and |{a,b,c}| = 3 = |N|-1
This is quite trivial if a set of nodes is small but if i scale up the number i quickly lose myself.1-2 => a 2-3 => b ...
Anyone encountered this problem before with an optimal solution?
PS: In real case scenario the number of nodes is close to 50
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Graph labeling problem
by choroba (Cardinal) on Feb 19, 2022 at 17:20 UTC | |
by LanX (Saint) on Feb 19, 2022 at 21:59 UTC | |
by choroba (Cardinal) on Feb 19, 2022 at 22:06 UTC | |
by LanX (Saint) on Feb 19, 2022 at 22:13 UTC | |
by baxy77bax (Deacon) on Feb 19, 2022 at 20:40 UTC | |
by etj (Priest) on Feb 20, 2022 at 15:47 UTC | |
by LanX (Saint) on Feb 20, 2022 at 15:53 UTC | |
by etj (Priest) on Feb 24, 2022 at 19:16 UTC | |
by LanX (Saint) on Feb 25, 2022 at 10:53 UTC | |
|
Re: Graph labeling problem
by talexb (Chancellor) on Feb 19, 2022 at 14:47 UTC | |
by LanX (Saint) on Feb 19, 2022 at 19:56 UTC | |
by baxy77bax (Deacon) on Feb 19, 2022 at 20:42 UTC | |
|
Re: Graph labeling problem
by tybalt89 (Monsignor) on Feb 19, 2022 at 21:59 UTC | |
by LanX (Saint) on Feb 20, 2022 at 12:28 UTC | |
by LanX (Saint) on Feb 20, 2022 at 13:04 UTC | |
|
Re: Graph labeling problem
by vr (Curate) on Feb 19, 2022 at 19:04 UTC | |
|
Re: Graph labeling problem
by LanX (Saint) on Feb 20, 2022 at 18:03 UTC | |
by LanX (Saint) on Feb 20, 2022 at 20:05 UTC |