用于在通信“网络”中查找故障案例的算法
我试图列举我正在开发的系统的一些失败案例,以便更轻松地编写测试用例。基本上,我有一组“点”,它们通过数据“路径”与任意数量的其他点进行通信。我想提出以下三组中的失败案例...
- 第 1 组 - 单独断开每条路径(微不足道)
- 第 2 组 - 对于系统中的每个点 P,断开路径,以便 P 与其余点完全切断系统(也是微不足道的)
- Set 3 - 对于系统中的每个点 P,断开路径,使系统分为两组点(A 和 B,不包括点 P),以便从 A 组到B组是通过P点(即我想强制系统中的所有数据流量通过P点以确保它能够跟上)。如果这对于特定点来说是不可能的,那么应该跳过它。
第 3 组是我遇到的麻烦。在实践中,我正在处理的系统足够小且简单,我可能可以“强力”找到一个解决方案(通常我有大约 12 个点,每个点连接到 1-4 个其他点)。但是,如果有人对从哪里开始有任何建议或想法,我有兴趣为此类问题找到更通用的算法。
I am trying to enumerate a number of failure cases for a system I am working on to make writing test cases easier. Basically, I have a group of "points" which communicate with an arbitrary number of other points through data "paths". I want to come up with failure cases in the following three sets...
- Set 1 - Break each path individually (trivial)
- Set 2 - For each point P in the system, break paths so that P is completely cut off from the rest of the system (also trivial)
- Set 3 - For each point P in the system, break paths so that the system is divided into two groups of points (A and B, excluding point P) so that the only way to get from group A to group B is through point P (i.e., I want to force all data traffic in the system through point P to ensure that it can keep up). If this is not possible for a particular point, then it should be skipped.
Set 3 is what I am having trouble with. In practice, the systems I am dealing with are small and simple enough that I could probably "brute force" a solution (generally I have about 12 points, with each point connected to 1-4 other points). However, I would be interested in finding a more general algorithm for this type of problem, if anyone has any suggestions or ideas about where to start.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一些伪代码,用常见的图论术语“节点”替换“点”和“假设一条路径连接两点,则“路径”的“边”。
除非我误解了什么,否则只要你有一种生成节点子集 - {P} 的方法,问题看起来就相对简单。这将测试每个分区 [A,B] 两次,除非您在那里进行其他检查。
Here's some psuedocode, substituting the common graph theory terms of "nodes" for "points" and "edges" for "paths" assuming a path connects two points.
Unless I'm misunderstanding something, the problem seems relatively simple as long as you have a method of generating the subsets of nodes-{P}. This will test each partition [A,B] twice unless you put some other check in there.
有一些用于“着色”网络的通用算法(有或没有 au,具体取决于您想要英国还是美国的文章)网络。然而,对于您描述的相对简单的问题来说,这太过分了。
只需将节点划分为两组,然后使用伪代码:
要么使用 rand 选择要恢复的断开链接,要么一次系统地恢复一个
重复 b (或构建边缘,使一个方向的中断影响另一个方向)
There are general algorithms for 'coloring' (with or without a u depending on whether you want UK or US articles) networks. However this is overkill for the relatively simple problem you describe.
Simply divide the nodes between two sets, then in pseudo-code:
Either use rand to chosse a broken link to reinstate, or systematically reinstate one at a time
Repeat for b (or structure your edges such that a break in one direction affects the other)