#19520: implement random triangulations in a bijective way
-------------------------+-------------------------------------------------
Reporter: | Owner:
chapoton | Status: needs_review
Type: | Milestone: sage-6.10
enhancement | Resolution:
Priority: major | Merged in:
Component: graph | Reviewers: Nathann Cohen
theory | Work issues:
Keywords: | Commit:
random graph | 3a7356b7b4b667ebdaa8f955452e7c8aaefa283c
Authors: | Stopgaps:
Frédéric Chapoton |
Report Upstream: N/A |
Branch: |
public/19520 |
Dependencies: |
-------------------------+-------------------------------------------------
Comment (by ncohen):
Hello Frédéric,
I thought about it for a while and ended up with the following design: a
function scans for a pattern through a list l and -- if it finds it --
rotates l so that it starts with that pattern.
Here is the code, hoping that it may help rewrite your code a bit more
clearly:
{{{
#!python
def rotate_l_to_next_pattern(pattern):
global l
# Find 'pattern' in l, and rotates l so that l starts with 'pattern'.
for i in range(len(l)):
if all(l[i+ii] == x for ii,x in enumerate(pattern)):
l = l[i:] + l[:i]
return True
return False
l = [0,1,0,0,0,0,0,1,1,0,1,0,1]
while rotate_l_to_next_pattern([0,1]):
l[0] = 2
}}}
Nathann
--
Ticket URL: <http://trac.sagemath.org/ticket/19520#comment:36>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.