Let n
be a positive integer. I would like to define a directed graph gr[n_,a_,b_]
(actually a bounded poset) as follows:
- Level 0: we start with a vertex labeled by the list
{1,2,1,3,2,1,...,n,n-1,...,1}
(denoted byg
for greatest element) - Level 1: we add vertices again labeled by lists of length ${n+1 \choose 2}$ that are created from
g
in two different ways:- for every consecutive sequence in
g
of the formk,k+1,k
we add a vertex labeled again byg
, except that we substitute the sequencek,k+1,k
byk+1,k,k+1
. We attach the vertexg
to every of the added vertices with a directed edge and label all of these edges witha
. - for every consecutive sequence in
g
of the formk,l
with|k-l|>1
we add a vertex labeled again byg
, except that that we substitute the sequencek,l
byl,k
. We attach the vertexg
to every of the added vertices with a directed edge and label all of these edges withb
. It is forbidden to resubstitutel,k
withk,l
again in the next level (and only in the next level) otherwise this algorithm wouldn't terminate.
- for every consecutive sequence in
- we iterate the procedure until we reach the last level with exactly one vertex with label
{n,n-1,n-2,...,1,...n,n-1,n-2,n,n-1,n}
(the least element in the poset)
As an example, I drew a picture of gr[3,a,b]
:
Actually, the graph itself is not important to me, I only need an output in the end from which I can extract the information how many a
's and b
's are on the path from g
to every other vertex v
.
Of course, I don't expect you to give me a full solution to this problem. For starters I would just like to know if you think this is realizable in Mathematica and maybe a suggestion what kind of Mathematica functions is typically used for these type of problems. In particular, how to define a directed graph with labeled edges and vertices in a step-by-step way?
NestGraph[]
? $\endgroup$