计算n*n网格生成树的数目,网格,[Python]代码Py
计算n*n网格生成树的数目,网格,[Python]代码Py
[Python]代码
Python语言: 计算n*n网格生成树的数目from math import cos"""[1] http://en.wikipedia.org/wiki/Kirchhoff's_theorem[2] http://www.research.att.com/~njas/sequences/A007341[3] Direct Methods for Computing Eigenvalues of the Finite-Difference LaplacianJ. R. KuttlerSIAM Journal on Numerical Analysis, Vol. 11, No. 4 (Sep., 1974), pp. 732-740 """def eigenvalues_of_laplacian(n): ew = [2*(2-cos(i*pi/n)-cos(j*pi/n)) for i in range(n) for j in range(n)] return ewdef num_of_spanning_trees(n): ew = eigenvalues_of_laplacian(n) return reduce(lambda x,y:x*y, ew[1:])/n**2
相关内容
- python实现统计word的小程序,pythonword小程序,[Python]代码
- HTML颜色和RGB颜色互转,html颜色rgb,[Python]代码Py
- 常见的Python字符串操作和一下小技巧,python字符串,[P
- python中获取按键(跨平台),python获取按键,[Python]代码P
- Python将内容中的Url地址转换成Tinyurl地址,pythontinyurl,
- 计算今天是一年中的第几周,计算一年第几周,[Python]代
- 多线程下载地址检测url_download,多线程url_download,#!/us
- 求素数的快速算法,素数算法,[Python]代码Py
- 组合生成与数量计算(Combinaton generator and counter),,[Pyt
- 生成华容道所有可求解的开局含镜像263977种,不含镜像
评论关闭