Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Cycle in Directed Graph

by dragonchild (Archbishop)
on Sep 21, 2005 at 02:18 UTC ( [id://493644]=note: print w/replies, xml ) Need Help??


in reply to Cycle in Directed Graph

sk's answer is technically correct. However, my experiences has been that one very rarely has a completely generic graph. Usually, there's additional information about how the graph is built that can remove the NP-completeness from a find_all_cycles() function.

A few items to look for could be:

  • You don't have any edges that loopback to the same vertex.
  • You can guarantee either an even or odd number of edges leading into or out of every vertex.
  • You can break your graph up into sub-graphs where any cycles cannot contain vertices in more than one sub-graph.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://493644]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-03-29 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found