From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cd5005cccfba0311 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!v45g2000cwv.googlegroups.com!not-for-mail From: "isaac2004" Newsgroups: comp.lang.ada Subject: Re: Topological Sort Help Date: 8 Feb 2007 10:53:37 -0800 Organization: http://groups.google.com Message-ID: <1170960817.632329.117990@v45g2000cwv.googlegroups.com> References: <1170618852.885855.258390@j27g2000cwj.googlegroups.com> <87sldllhpt.fsf@ludovic-brenta.org> <1170707421.136089.281290@l53g2000cwa.googlegroups.com> <87y7ncjq4y.fsf@ludovic-brenta.org> <1170728294.194370.133540@k78g2000cwa.googlegroups.com> <1170752808.678318.252960@l53g2000cwa.googlegroups.com> <1170897552.495666.223180@v33g2000cwv.googlegroups.com> NNTP-Posting-Host: 140.160.105.171 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1170960837 13439 127.0.0.1 (8 Feb 2007 18:53:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Feb 2007 18:53:57 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: v45g2000cwv.googlegroups.com; posting-host=140.160.105.171; posting-account=bWy1LAwAAAAtVkasDCH0ykMCBMNd-FcL Xref: g2news2.google.com comp.lang.ada:9157 Date: 2007-02-08T10:53:37-08:00 List-Id: an exit when makes no sense in this situation because there is no finite stopping condition, if you look at the algorithm provided, i see it harder top implement an exit when loop WHILE IsEmpty(G) /= False DO -- S := set of all vertices in V who have no sucessors -- if S is empty -- hascycle := true; -- return hascycle -- end if -- take the greatest element e in S -- push e onto a stack -- remove all edge in E that have e as a destination -- remove e from v -- end loop if i am wrong please show me an algorithm that would work, thanks On Feb 8, 10:38 am, "Jeffrey R. Carter" wrote: > isaac2004 wrote: > > the topological sort that i am trying to accomplish from this > > structure will follow the algorithm that i have created from > > others(its pretty much the same) the problem is im having trouble > > setting up the while loop to traverse the array of digraph information > > An easy way to avoid confusing while loops is not to use them. Instead of > > Name : while Unintuitive_Negative_Logic_For_Loop_Continuation loop > > use > > Name : loop > exit Name when Intuitive_Positive_Logic_For_Loop_Exit; > > While loops, with their continuation condition, are generally better if > you're doing correctness proofs, but if you're not, using exit > conditions is usually clearer and more intuitive. > > -- > Jeff Carter > "What I wouldn't give for a large sock with horse manure in it." > Annie Hall > 42