graph traversal

This is a discussion on graph traversal within the C Programming forums, part of the General Programming Boards category; i need help writing a program that involves graph traversal... how do i read in the graph from a file ...

  1. #1
    Unregistered
    Guest

    graph traversal

    i need help writing a program that involves graph traversal... how do i read in the graph from a file whose name is specified on the command-line?
    Also, how can i do the following?
    1.) Ask the user what node to start at, and whether to perform breadth-first or depth-first traversal
    2.) Put the graph-specific code into a library of graph-related functions (ie, like the Stack and Queue libraries).
    thanks!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    What have you come up with so far?

    -Prelude
    My best code is written with the delete key.

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >how do i read in the graph from a file whose name is specified
    >on the command-line?

    Declare a pointer to FILE, then use fopen to open the file. Reading can be done by for example fgetc or fread.

    >Ask the user what node to start at, and whether to perform
    >breadth-first or depth-first traversal

    You could use scanf to get the option from the user.

    >Put the graph-specific code into a library of graph-related
    >functions (ie, like the Stack and Queue libraries).

    Use fputc, fwrite, something like that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error help making no sense
    By tunerfreak in forum C++ Programming
    Replies: 5
    Last Post: 04-17-2007, 08:55 PM
  2. scene graph rendering techniques
    By ichijoji in forum Game Programming
    Replies: 7
    Last Post: 03-19-2006, 12:17 AM
  3. determining a path through the graph
    By Mist in forum C Programming
    Replies: 2
    Last Post: 02-27-2005, 12:21 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Minimize crossing edges in undirected graph
    By Shiro in forum C Programming
    Replies: 0
    Last Post: 12-26-2001, 04:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21