Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: H of A optimization

by abitkin (Monk)
on Aug 31, 2002 at 15:40 UTC ( [id://194345]=note: print w/replies, xml ) Need Help??


in reply to Re: H of A optimization
in thread H of A optimization

Actually I was turning an aciclic undirected graph into a spanning tree, so removing 2 4 was the correct approach. The code I posted works correctly for me, with that and some help I got on the CB, I went from 80+ minutes of run time, to 15.

Thanks for your thoughts though

Replies are listed 'Best First'.
Re: Re: Re: H of A optimization
by sauoq (Abbot) on Aug 31, 2002 at 18:57 UTC
    Actually I was turning an aciclic undirected graph into a spanning tree,

    But you weren't.

    Firstly, the data you started with was not acyclic (the edges 1-2, 1-4, and 2-4 composed a cycle) and you treated it as if it were directed by paying special attention to the nodes on the right side of your input edges. Secondly and more importantly, your algorithm won't guarantee that the resulting graph is connected or acyclic, the two requirements for a spanning tree.

    so removing 2 4 was the correct approach.

    If the nodes had been listed as 2-1, 1-4, 4-2 the cycle would not have been eliminated.

    The code I posted works correctly for me, with that and some help I got on the CB, I went from 80+ minutes of run time, to 15.

    I'm glad you got an answer that worked for you. Certainly the code you posted was not very efficient. But efficiency is meaningless without correctness and your statement of the problem leaves some question about the solutions.

    Maybe you could summarize the help you got on the CB for those monks who may stumble upon this node while seeking enlightenment on their own graph related problems.

    Good luck!

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found