From: "isaac2004" <isaac_2004@yahoo.com>
Subject: Re: Topological Sort Help
Date: 7 Feb 2007 17:19:12 -0800
Date: 2007-02-07T17:19:12-08:00 [thread overview]
Message-ID: <1170897552.495666.223180@v33g2000cwv.googlegroups.com> (raw)
In-Reply-To: <1170752808.678318.252960@l53g2000cwa.googlegroups.com>
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" <ludo...@ludovic-brenta.org>
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.
next prev parent reply other threads:[~2007-02-08 1:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-04 19:54 Topological Sort Help isaac2004
2007-02-04 21:45 ` Ludovic Brenta
2007-02-05 20:30 ` isaac2004
2007-02-05 20:39 ` Ludovic Brenta
2007-02-06 2:18 ` isaac2004
2007-02-06 9:06 ` Ludovic Brenta
2007-02-08 1:19 ` isaac2004 [this message]
2007-02-08 9:25 ` Ludovic Brenta
2007-02-08 18:14 ` isaac2004
2007-02-08 18:24 ` Ludovic Brenta
2007-02-08 18:29 ` isaac2004
2007-02-08 18:54 ` Ludovic Brenta
2007-02-08 19:14 ` isaac2004
2007-02-08 19:27 ` Ludovic Brenta
2007-02-08 20:22 ` isaac2004
2007-02-09 2:04 ` isaac2004
2007-02-08 18:38 ` Jeffrey R. Carter
2007-02-08 18:53 ` isaac2004
2007-02-09 4:57 ` Jeffrey R. Carter
2007-02-10 8:37 ` s053914
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox