1 | initial version |
Not entirely clear what the question was. Or was this an implementation request?
In case you were looking for an implementation, here is a possible way of doing it. :-)
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
xle_relations = lambda le_relations: [["x{0}".format(a),"x{0}".format(b)] for a,b in le_relations]
[xle_relations(le_relations(P)) for P in posets(n) if P.is_connected()]
We use the le_relations
to compute a list of pairs (a,b)
where (a,b)
is in the list if and only if a
<b
in a poset P
. The xle_relations
is just switching to the format you are interested in, that is, converting to a pair of strings prefixed by "x"
.
The last line iterates through all posets via posets(n)
and they are filtered via the is_connected
method. Getting a function from these three lines should be easy, the three lines of code only depend on n
being defined.
Hope this is useful.
2 | No.2 Revision |
Not entirely clear what the question was. Or was this an implementation request?
In case you were looking for an implementation, here is a possible way of doing it. :-)
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
xle_relations = lambda le_relations: [["x{0}".format(a),"x{0}".format(b)] for a,b in le_relations]
what_you_want = lambda n: [xle_relations(le_relations(P)) for P in posets(n) if P.is_connected()]
We use the le_relations
to compute a list of pairs (a,b)
where (a,b)
is in the list if and only if a
<b
in a poset P
. The xle_relations
is just switching to the format you are interested in, that is, converting to a pair of strings prefixed by "x"
.
The last line iterates through all posets via posets(n)
and they are filtered via the is_connected
method. Getting a function from these three lines should be easy, the three lines of code only depend on n
being defined.
what_you_want(4)
[[['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3']], [['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x3'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3']], [['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3'], ['x2', 'x3']]]
Hope this is useful.
3 | No.3 Revision |
Not entirely clear what the question was. Or was this an implementation request?
In case you were looking for an implementation, here is a possible way of doing it. :-)
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
xle_relations = lambda le_relations: [["x{0}".format(a),"x{0}".format(b)] cover_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in le_relations]
P.hasse_diagram().edges(labels=None)]
format_pt = lambda k: "'x{0}'".format(k+1)
format_relations = lambda relations: [[format_pt(a),format_pt(b)] for a,b in relations]
format_pts = lambda P: [format_pt(a) for a in P]
format_poset = lambda P: [format_pts(P), format_relations(cover_relations(P)), format_relations(le_relations(P))]
what_you_want = lambda n: [xle_relations(le_relations(P)) [format_poset(P) for P in posets(n) if P.is_connected()]
We use the Now you should be able to just issue:
le_relationswhat_you_want(3) [[["'x1'", "'x2'", "'x3'"], [["'x1'", "'x2'"], ["'x1'", "'x3'"]], [["'x1'", "'x2'"], ["'x1'", "'x3'"]]], [["'x1'", "'x2'", "'x3'"], [["'x1'", "'x2'"], ["'x2'", "'x3'"]], [["'x1'", "'x2'"], ["'x1'", "'x3'"], ["'x2'", "'x3'"]]], [["'x2'", "'x1'", "'x3'"], [["'x1'", "'x3'"], ["'x2'", "'x3'"]], [["'x1'", "'x3'"], ["'x2'", "'x3'"]]]]
Observe that if you just wish to compute format a list of pairs single poset, you can do so via
where (a,b)(a,b)
is in the list if and only if a
<b
in a poset P
. The xle_relations
is just switching to the format you are interested in, that is, converting to a pair of strings prefixed by "x"format_poset
.
The last line iterates through all posets via posets(n)
and they are filtered via the is_connected
method. Sample usage below:
what_you_want(4)
[[['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3']], [['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x3'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3']], [['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3']], [['x0', 'x1'], ['x0', 'x2'], ['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3'], ['x2', 'x3']], [['x0', 'x3'], ['x1', 'x2'], ['x1', 'x3'], ['x2', 'x3']]]
Hope this is useful.
Update: Adapted to new output format.
4 | No.4 Revision |
Not entirely clear what the question was. Or was this an implementation request?
In case you were looking for an implementation, here is a possible way of doing it. :-)
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
cover_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.hasse_diagram().edges(labels=None)]
format_pt = lambda k: "'x{0}'".format(k+1)
format_relations = lambda relations: [[format_pt(a),format_pt(b)] for a,b in relations]
format_pts = lambda P: [format_pt(a) for a in P]
format_poset = lambda P: [format_pts(P), format_relations(cover_relations(P)), format_relations(le_relations(P))]
what_you_want = lambda n: [format_poset(P) for P in posets(n) if P.is_connected()]
Now you should be able to just issue:
what_you_want(3)
[[["'x1'", "'x2'", "'x3'"],
[["'x1'", "'x2'"], ["'x1'", "'x3'"]],
[["'x1'", "'x2'"], ["'x1'", "'x3'"]]],
[["'x1'", "'x2'", "'x3'"],
[["'x1'", "'x2'"], ["'x2'", "'x3'"]],
[["'x1'", "'x2'"], ["'x1'", "'x3'"], ["'x2'", "'x3'"]]],
[["'x2'", "'x1'", "'x3'"],
[["'x1'", "'x3'"], ["'x2'", "'x3'"]],
[["'x1'", "'x3'"], ["'x2'", "'x3'"]]]]
Observe that if you just wish to format a single poset, you can do so via format_poset
.
Hope this is useful.
Update: Adapted to new output format.