Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...