Many problems of the Internet of Things (IoT), such as radio frequency allocation and sensor network, can be regarded as constraint optimal problems (COPs), which can be formulated as graphical representations. The scale of graph is large, which is hard to implement, and the information shared by all the variables is unsafe for all the variables running in an agent. On the other hand, supercomputers are playing a significant and growing role in various fields of large-scale processing tasks. When countering this scene, the supercomputers can accelerate to complete the task according to the distributed solution, where they divide the task into sub-tasks and each sub-task is running on an agent, such as a process or a computation node. However, finding an optimal distributed solution is difficult to minimize the completion time with the optimal computing resources. Putting the task on too many agents not only wastes resources but also increases the risk of attacks. Conversely, fewer agents may take too much time, which is unacceptable for users. Determining the number of agents needs to strike a balance between communication and computation. In this paper, we propose a new framework GVPNN for predicting the optimal numbers of agents for COPs and further provide the allocation from variable to agent. Experimental result shows the framework can learn the structure of the corresponding graphical representation well, and the 1-distant accuracy rate and the top 3 accuracy rate of GVPNN reach 74% and 70%, respectively.