计算任意一个图生成树的个数——Kirchhoff 的Matrix Tree 方法Java实现

本文介绍了如何利用Kirchhoff的Matrix Tree定理计算图的生成树个数,通过Java实现。核心是使用LUP分解法来高效地求解矩阵的余子式,从而得到生成树的数量。
摘要由CSDN通过智能技术生成
计算任意一个图的生成树的个数,是Kirchhoff提出的理论,通常称为Matrix Tree Theorem,原理很简单:

Let G be a graph with V(G)={v1,v2,...,vn},let A={aij}be the adjacentcy matrix of G,and let C={cij}be the n*n matrix, where cij=deg vi if i=j; cij=-aij if i!=j; Then the number of spanning trees of G is the vlaue of any cofactor(余子式) of C

但是需要计算行列式的值,这里需要点小技巧,所以这里选择了LUP分解法来计算。

package trees;

import matrix.DeterminantCalculator;

/**
 * 计算任意一个图的生成树的个数,是Kirchhoff提出的理论,通常称为Matrix Tree Theorem
 * Let G be a graph with V(G)={v1,v2,...,vn},let A={aij}be the adjacentcy matrix of G,
 * and let C={cij}be the n*n matrix, where cij=deg vi if i=j; cij=-aij if i!=j; Then the
 * number of spanning trees of G is the vlaue of any cofactor(余子式) of C
 * @author xhw
 *
 */
public class NumberOfSpanningTree {

	
	/**
	 * @param args
	 */
	public static void mai
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值