A graph application

C

candy

hi all,
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.

Thanks in Advance,

Candice.
 
M

Mark A. Odell

(e-mail address removed) (candy) wrote in

hi all,
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.

Me either. We'll help you with the C language, but not with writing
project code. Graphing is typically not part of C unless simple text based
"graphs" are sufficient.
Thanks in Advance,

Never thank in advance, you may not get what you asked for and you'll have
wasted a perfectly good thank you.
 
E

Elliott Back

Mark said:
Me either. We'll help you with the C language, but not with writing
project code. Graphing is typically not part of C unless simple text based
"graphs" are sufficient.

What he's looking for is not plotting and charting applications, but
graph search. You'll want to represent the filesystem as a set of
nodes, with a root node representing the root of your drive holding some
variable number of directory and file nodes. You may want to order the
nodes in some way. Google for "Depth first search", "Breadth first
search", "A*", and "Graph search algorithms."
 
?

=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=

Malcolm said:
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.
Are such refrences worth caring about ? Are there any OS's that have
such constructs that can not be seperated from a "normal" directory ?
e.g. on unix we have symlinks, traversing directories here one could
just ignore them, as one should reach the pointed-to file/dir from
elsewhere.
 
M

Malcolm

candy said:
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.
 
M

Minti

candy said:
hi all,
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.

Thanks in Advance,

Candice.

Have you tried Google Desktop. Not sure if it does through graphs but surely
fast.


--
Imanpreet Singh Arora
Zmoc.Zliamg@Zteerpnami
Remove Z to mail
"Things may come to those who wait, but only the things left by those who
hustle."
Abraham Lincoln
 
M

Malcolm

Nils O. Selåsdal said:
Are such refrences worth caring about ? Are there any OS's that have
such constructs that can not be seperated from a "normal" directory ?
e.g. on unix we have symlinks, traversing directories here one could
just ignore them, as one should reach the pointed-to file/dir from
elsewhere.
For real code, probably not. However if it is a learning exercise the
teacher might say "let's pretend there is no way of distinguishing a linked
directory from one with only one reference, how would you detect a cycle?"
 
M

Michael Wojcik

For real code, probably not. However if it is a learning exercise the
teacher might say "let's pretend there is no way of distinguishing a linked
directory from one with only one reference, how would you detect a cycle?"

Real code has to deal with real data. In this case, that would
include malformed directory structures.

There certainly *are* OSes in wide use which make it possible to
create directory loops. They may be errors; that doesn't mean it's
impossible for a program to encounter them.

One of the most important lessons for people writing non-trivial C
code is that input can be invalid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,206
Latest member
SybilSchil

Latest Threads

Top