Re: A graph application

From: Malcolm (malcolm_at_55bank.freeserve.co.uk)
Date: 10/13/04


Date: Wed, 13 Oct 2004 21:49:16 +0100


"candy" <candy_init@yahoo.com> wrote
> I have to make a program in C while using graphs.The aim of the project
> is to search the contents of a computer in the lowest possible time.
> Can you please tell me how I can do this while using graphs.
> Basically i have no idea that how the inputs can be given to graphs.
>
Basically you are starting at the root directory, pulling out all files that
match your search criteria, and then doing the same recursively to all
sub-directories.

The fun comes when sub-directories are allowed to contain references to
parent directories, creating a loop.

Depending on your system, you might be able to maintain a fully-qualified
directory list, from root to the directory you are currently searching, and
check for loops against that. This however is rather cheating.

What you can do is keep track of recursion depth, then start at the root and
search downwards, looking for loops. If you don't find a loop, the directory
is not a link to a parent, and you can continue as normal.

However how do you distinguish an apparent loop from a sub-directory set up
to look like a parent? This would only happen if someone was deliberately
trying to fool your program. You could set a limit of, say, 1000 iterations
before you accept that the loop is genuinely a loop.



Relevant Pages

  • flush writing to multiple children IO::Pipe
    ... one will receive random data from their STDIN from the parent. ... the parent's loop that writes to each child seems to have to finish ... a more desired behavior is to ... printFinished sending messages. ...
    (comp.lang.perl.modules)
  • Re: File handle re-use woes using pipe within a loop
    ... > child will die before the parent has read the output from it. ... > definitions within the while loop. ... The whole point of 'my' variables is that when they go out of scope ...
    (comp.lang.perl.misc)
  • Re: advices on sockets
    ... child processes are not dependent on the parent. ... connections, and other threads process existing connections. ... if I don't make the socket non-blocking the loop hangs on select. ...
    (comp.unix.programmer)
  • easy AOP right now using evil.rb
    ... Here is a pure ruby soluntion to doing AOP. ... then having the parent "become" the child is very similar to ... Class#replace and that be able to break circular loops ... automatically instead of having to use #clone to break the loop ...
    (comp.lang.ruby)
  • Re: easy AOP right now using evil.rb
    ... sub-classing and then having the parent "become" the child is very similar to the proposed "cut". ... Class#replace and that be able to break circular loops automatically instead of having to use #clone to break the loop manually. ... The problem is that it is not possible to add a wrapper class this way without breaking existing code, or at least without that code messing with your advice. ...
    (comp.lang.ruby)