作为拼图求解器的一部分,我从用户输入中动态构建图形,节点和边缘。
每个节点均分配一个整数const,代表其一部分连接的组件。
节点仅限于与邻居相同的连接组件。
当前,它可以将相同的数字分配给多个组件,但是我想限制解决方案,以便每个连接的组件必须具有唯一的数字。
我无法围绕如何在Z3中表达这种约束。
我不是在寻找工作代码,只是关于如何处理此问题的高级描述,我可以从那里进行。
提前致谢!
As part of a puzzle solver, I dynamically build a graph, nodes and edges, from user input.
Each node is assigned an integer const, representing which connected component it is part of.
Nodes are restricted to have the same connected component as their neighbors.
Currently, it can assign the same number to multiple components, but I want to restrict the solution so that each connected component must have a unique number.
I cannot wrap my head around how to express this constraint in Z3.
I'm not looking for working code, just a high level description of how to approach this, and I can take it from there.
Thanks in advance!
发布评论
评论(1)
可以使用。
以下片段可能会让您入门:
Nodes of a graph component connected via other nodes can be modelled using TransitiveClosure.
The following snippet might get you started: