简体   繁体   中英

Print the edges (points) of undirected graph

How I can print the points : I mean "(x,y)" of a cycle in a graph ? . I am stuck there. I don't know how to print the points that are on the cycle.

Imagine the algorithm you are running as movements along the graph. In order to detect a cycle, you check every possible movement from a starting position whether it brings you back to the starting position. This you do recursively for any adjacent vertex. Now, when you detect a cycle, your path resembles the recursive calls that you made.

A few notes:

  • Since this is clearly homework, I'm not giving you a full solution but enough of a hint.
  • If you have trouble imagining this as movement, print the current position at different points during program execution.
  • I don't think your algorithm is implemented correctly. Make sure that you have a few test cases to verify that it does what it should.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM