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!v33g2000cwv.googlegroups.com!not-for-mail From: "isaac2004" Newsgroups: comp.lang.ada Subject: Re: Topological Sort Help Date: 7 Feb 2007 17:19:12 -0800 Organization: http://groups.google.com Message-ID: <1170897552.495666.223180@v33g2000cwv.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> NNTP-Posting-Host: 140.160.138.223 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1170897558 24966 127.0.0.1 (8 Feb 2007 01:19:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Feb 2007 01:19:18 +0000 (UTC) In-Reply-To: <1170752808.678318.252960@l53g2000cwa.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04324.17; InfoPath.1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: v33g2000cwv.googlegroups.com; posting-host=140.160.138.223; posting-account=bWy1LAwAAAAtVkasDCH0ykMCBMNd-FcL Xref: g2news2.google.com comp.lang.ada:9119 Date: 2007-02-07T17:19:12-08:00 List-Id: 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 PROCEDURE Topological_Sort ( G : IN Digraph; Result : OUT Stackpointer; Hascycle : OUT Boolean) IS S : Set; BEGIN -- 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 this is the algorithm i have, the while loop makes sure the graph is not a cycle(if it does that kicks out) if there is no cycle it takes the vertes with no sucessors and adds it to a stack. is this setup possible, if so setting up the if statement nested for loops is throwing me off, i have functions like FUNCTION IsStronglyConnected ( G : Digraph) RETURN Boolean IS EdgeSet : Set; VertexSet : Set; BEGIN FOR I IN G'RANGE LOOP VertexSet := VertexSet + Character(I); FOR J IN G'RANGE LOOP IF G(I,J) = True AND I /= J THEN EdgeSet := EdgeSet + Character(J); END IF; END LOOP; END LOOP; IF VertexSet <= EdgeSet THEN RETURN True; ELSE RETURN False; END IF; END IsStronglyConnected; that checks connectivity of the graph and this is the style i have been using. can i get any help with the top sort. thanks so much any advice would be great On Feb 6, 1:06 am, "Ludovic Brenta" wrote: > On Feb 6, 3:18 am, "isaac2004" wrote: > > > "fpund online" is right i know the basics of how it works but > > implementing anything into it is the part im getting stuck at. any > > help > > It is my policy not to do students' assignments for them. That would > be a disservice, as the purpose of assignments is to make students > think and work; that's the only real way of learning. So far, apart > from searching "online" and asking questions here, you have not shown > evidence of doing any actual work. I will help you with specific > questions when you post your program and explain the part you don't > understand. In the mean time, you would be better advised to ask your > teacher - it's their job to help you understand the basics. > > If you are not a student, my apologies. > > -- > Ludovic Brenta.