问题描述
我正在一个项目中,我想提出一个非常基本的模拟,该模拟可以根据用户输入来估计一张纸的姿势。
因此,您将开始使用一张平面纸,其节点为0、1、2、3。 我希望将这些节点放置在坐标上,以便创建一张矩形纸。然后,按顺序从节点0到节点3添加边。 到目前为止,为实现此目的,我编写了以下代码:
import networkx as nx
import matplotlib.pyplot as plt
G=nx.Graph()
pos = {0:(0,0),1:(0,20),2:(10,3:(10,0)}
G.add_nodes_from(pos)
G.add_edge(0,1)
G.add_edge(1,2)
G.add_edge(2,3)
G.add_edge(3,0)
nx.draw(G,pos)
plt.show()
我一直在想象这张纸:
我已经提出了一些合理的方式来进行该项目,但是我对networx没有太多的经验,因为我对编程总体上还是很陌生的。 以下是我将要设计的一般结构的图像:
#Imports
#Initialise graph
#Set base node values
#Add edges between base nodes
#Interactive way to add edges
#Draw line across any 2 edges
#Identify the "new" nodes created by intersecting line
#Check whether gradient of new edge is positive or negative
#If positive
#See which nodes are to the left of edge line
#List said nodes
#Get 90 degree angle and distance to said nodes,relative to new edge line
#Create new nodes with coordinates that are inverse and across the intersecting line
#If negative
#See which nodes are to the right of edge line
#List said nodes
#Get 90 degree angle and distance to said nodes,relative to new edge line
#Create new nodes with coordinates that are inverse and across the intersecting line
在进行了这些更改之后,根据状态0的图像,以下状态1应该看起来与此类似:
我希望在项目的任何方面提供帮助。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)