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 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!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Thu, 08 Feb 2007 03:25:08 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Topological Sort Help 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> Date: Thu, 08 Feb 2007 10:25:07 +0100 Message-ID: <87ps8ldmrw.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:8aCnVwZTeseYFP08gI+iH5M86Us= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.202.12 X-Trace: sv3-F5GKzvWTSwLFtG/1R2iSyH38ZlcTaU+dAeKfkGs2g9DaBnQtK01/5o8p1ZDC35BU9JF0MwFzi9iHCGt!tJZ05nfWEoWTIRci5/4o/VFtMLqtc6wmVhGoW6HzBf+3JWYW1ue6tA8gGnCEb3foUYoEDze0VQ== X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:9129 Date: 2007-02-08T10:25:07+01:00 List-Id: isaac2004 writes: > 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 OK, at this point it would make more sense if you would post your entire program. Without the type definitions for Set, Digraph, and Stackpointer, there is little anyone can do. Also we'd need the definitions of operations on those types. So, post your entire program. > PROCEDURE Topological_Sort ( > G : IN Digraph; > Result : OUT Stackpointer; > Hascycle : OUT Boolean) IS > > S : Set; > BEGIN > -- WHILE IsEmpty(G) /= False DO You should simply write 'while not IsEmpty (G) do'. > -- S := set of all vertices in V who have > no sucessors What is V? > -- if S is empty > -- hascycle := true; > -- return hascycle Jusr "return". This is a procedure, not a function. > -- end if > -- take the greatest element e in S Which assumes an ordering relationship between elements of S. Please define function "<" (Left, Right : in Element) whatever Element is (presumably Vertex?). > -- push e onto a stack I see you already have a type Set which looks like a stack, so I assume that's the type you want to use here? > -- remove all edge in E that have e as a destination What is E? The stack? > -- 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); Why do you convert I to a Character? Do you think that a node is a Character? Also, there appears to be a function "+" (Left : in Set; Right : in Character) return Set; which we know nothing about. Please post your entire program. > FOR J IN G'RANGE LOOP > IF G(I,J) = True AND I /= J THEN Better write 'if G (I, J) 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; Better write 'return VertexSet <= EdgeSet'. Also, there appears to be a function "<=" (Left, Right : in Set) return Boolean; which is not defined. Please post your entire program. > 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 -- Ludovic Brenta. Because it's messing up the reading order. >Why? >>Please stop top-posting.