解决源和汇之间的受限连接
patchpanel的Python项目详细描述
接线板
Patch Panel是一个Python库,用于解决源和汇之间的受限连接问题。源和汇可以是任意的(散列的)对象,连接以简单的元组列表的形式返回。这个库不保证唯一的解决方案,它只是返回满足所有约束的第一个合法解决方案。在
安装
安装配线架的最简单方法是从PyPI获取它:
$> pip install patchpanel
也可以手动安装:
^{pr2}$示例
frompatchpanel.problemimportProblem# Create I/Osources=[f"src_{x}"forxinrange(2)]sinks=[f"snk_{x}"forxinrange(2)]# Create the problemproblem=Problem(sources,sinks)# Constrain to allow any-to-anyproblem.constrain(sources,sinks)# Solveconns,u_src,u_sink=problem.solve()# Displayprint(f"Connections: {conns}")print(f"Uncon. src : {u_src}")print(f"Uncon. sink: {u_sink}")
运行测试
Patch Panel附带一套基本测试,使用pytest
进行回归:
$> git clone git@github.com:Intuity/patchpanel
$> cd patchpanel
$> python3 setup.py test
- 项目
标签: