Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
GuillaumeLaplante-Anfossi
GitHub Repository: GuillaumeLaplante-Anfossi/Poissons
Path: blob/main/sage/mparking.sage
1017 views
1
2
def desc(l):
3
d = []
4
for i in range(0,len(l)-1):
5
if l[i]>l[i+1]:
6
d.append(i)
7
return d
8
9
10
# variante des fonctions de parking: suite de nb strictement positifs telle
11
# qu'une fois triée on reste sous 234...(n+1).
12
def park(n):
13
l = []
14
for i in range( n , sum(range(n+1,1,-1))+1 ):
15
for p in Partitions(i,length=n,outer=range(n+1,1,-1)):
16
print(p)
17
l += Permutations(p)
18
return l
19
20
21
# add( q**len(desc(list(p)+[1])) for p in park(2) )
22
# c'était un essai mais ça ne donne pas les nombres qu'on cherche
23
24
# le multigraphe Kn / e
25
def gr(n):
26
G = graphs.CompleteGraph(n)
27
G.allow_multiple_edges(true)
28
G.contract_edge(G.edges()[0])
29
return G
30
31
# gr(4).spanning_trees_count()
32
33
34