Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.4k views
in Technique[技术] by (71.8m points)

python - Check if line segments form connected undirected graph

I have a list of edges, given by a pair of coordinates (x, y) of the incident vertices, and I want to check, if these edges form connected undirected graph. what is the most efficient algorithm for this task?

Example with 'NO' answer:

  [((607.0, 250.0), (606.0, 270.0)),
 ((543.0, 167.0), (470.0, 173.0)),
 ((172.0, 319.0), (173.0, 329.0)),
 ((648.0, 652.0), (692.0, 688.0)),
 ((558.0, 488.0), (579.0, 469.0)),
 ((579.0, 469.0), (558.0, 488.0)),
 ((357.0, 699.0), (347.0, 650.0)),
 ((173.0, 329.0), (172.0, 319.0)),
 ((606.0, 270.0), (607.0, 250.0)),
 ((910.0, 452.0), (830.0, 473.0)),
 ((347.0, 650.0), (357.0, 699.0)),
 ((830.0, 473.0), (910.0, 452.0)),
 ((692.0, 688.0), (648.0, 652.0)),
 ((470.0, 173.0), (543.0, 167.0))]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...