Project 3: Graph Search

Creating graph search algorithms and applying them to solve maze problems

Version 10/20/16

Educational Objectives: After completing this assignment, the student should be able to accomplish the following:

Operational Objectives: Design, implement, and test various graph algorithms using the Graphs framework. Apply these algorithms to solve maze problems.

Deliverables: Three files with contents as follows:

filename            items requiring completion
--------            --------------------------
survey_util.h       Postorder
graph_util.h        OutDegreeDistribution, Path_BFS, Path_DFS
log.txt             work log

Graph Framework

The fsu Graph Framework consists of a number of classes, utility functions, and test harnesses. The following is a brief description of the files and their contents. These are discussed in considerably more detail in a companion guide.

FSU Graph Framework
FilenameContents
graph.h Class templates ALUGraph, ALDGraph. These implement adjacency list representations for undirected and directed graphs, respectively.
bfsurvey.h Class template BFSurvey. This class implements breadth-first survey as described in lecture notes.
Important engineering details are implemented that are not discussed in the class notes.
dfsurvey.h Class template DFSurvey. This class implements depth-first survey as described in lecture notes.
Important engineering details are implemented that are not discussed in the class notes.
graph_util.h A number of stand-alone functions assisting clients of the graph classes, including Load, Save, InDegreeFrequencyDistribution, ShowAL, Path_BFS, Path_DFS, and CheckSymmetry, along with several functions specifically supporting the test harnesses.
survey_util.h Stand-alone functions primarily supporting the test harnesses for graph surveys. Includes Levelorder, Preorder, Postorder, and WriteData.
topsort.h Function template TopSort implementing the Knuth topological sort algorithm.
fgraph.cpp Client test harness for graph class templates.
Arguments: (1) graph file (req), (2) log file (opt)
fbfsurvey.cpp Client test harness for BFSurvey class template. Can be configured for either undirected or directed graphs.
Arguments (all req): (1) graph file, (2) 'f'/'s' (full or single search), (3) start vertex number, (4) 1/0 (trace/no-trace).
fdfsurvey.cpp Client test harness for DFSurvey class template. Can be configured for either undirected or directed graphs.
Arguments (all req): (1) graph file, (2) 'f'/'s' (full or single search), (3) start vertex number, (4) 1/0 (trace/no-trace).
fpath.cpp Client test harness for Load, Path_BFS and Path_DFS. Reads graph file and displays BFS and DFS paths from x to y. Does both undirected and directed graphs.
Arguments (all req): (1) graph file, (2) from vertex, (3) to vertex.
ftopsort.cpp Client test harness for TopSort function template.
Argument: (1) graph file (req)
Maze Apps
maze_util.h Functions supporting the study of mazes using the graph framework, including LoadMaze and Maze2Graph
solvemaze.cpp Client test harness for Path_DFS, CheckSymmetry, and LoadMaze. Reads maze file, checks for consistency, solves the maze, and appends solution in maze file with ".dfs" extension.
Argument: (1) maze file (req).
maze2graph.cpp Client test harness for Maze2Graph. Reads maze file, writes graph file containing directed graph model of maze. Graph file same as maze filename with ".dg" extension.
Arguments: (1) maze file (req), (2) 1/0 (directed/undirected) (optional - default is directed)
printmaze.x Executable. Creates postscript file from maze file (with solution). Useful to print graphics and to include graphics in pdf documents.
Use with file redirect, and be sure to write to a file with ".ps" extension. (Written by Bret Whissel.)
ps2png.sh Executable. Converts postscript file to png file for visual display. Assumes "$1.ps" and writes "$1.png".
Argument: (1) .ps filename without ".ps" extension (req)
mazemaster.x Executable. Menu-driven maze analysis tool. Argument: command file (optional)

Please note: It is very important to understand all of the code listed above in complete detail and as it fits into the theory discussed in the lecture notes. Mastery of this software is part of the assignment.

Procedural Requirements

  1. Begin by copying all files from LIB/proj3 into your proj3 directory. All of these files require your familiarization with code, in conjunction with reading from the lecture notes.

    In addition you will want to copy the following executables:

    fgraph.x
    ftopsort.x
    fbfs_ug.x
    fbfs_dg.x
    fdfs_ug.x
    fdfs_dg.x
    

    After completing the project, You should be able to create these with the distributed makefile, but you should become familier with them while preparing your knowledge for the project. All of the executables are important to use to assist in understanding graphs and graph search algorithms.

    You may also want to copy some or all of the files from the graph framework, located in LIB/tcpp, since you will need to understand them in detail. If you copy these library files, be sure your code does not depend on these files being located in your project directory - that will not be true in your portfolio.

  2. Maintain your work log in the text file log.txt as documentation of effort, testing results, and development history. This file may also be used to report on any relevant issues encountered during project development.

  3. Create the deliverables listed above conforming to the requirements and specifications below.

  4. When logged in to shell or quake, submit the project by executing "submit.sh deliverables.sh". Read the screen and watch for processing errors.

    Warning: The submit process does not work on the program and linprog servers. Use shell or quake to submit projects. If you do not receive the second confirmation with the contents of your project, there has been a malfunction.

Code Requirements and Specifications

  1. The official development | testing | assessment environment is g++ -std=c++11 -Wall -Wextra on the linprog machines. Code should compile without error or warning.

  2. Algorithms should be fully compatibility with the fsu graph framework as released in the course library and should use that library whenever possible. Re-inventing the various features and components of the library is not appropriate.

  3. Graph and Maze file specifications, as given in the course notes and previous assignments, should be adhered to.

  4. Where appropriate, algorithms should be tested on both undirected and directed cases. Note that a number of examples are given, and the graph file format can be interpreted as both undirected and directed graph.

  5. OutDegreeDistribution

    Use the following header:

    template < class G >
    void OutDegreeDistribution (const G& g, size_t maxToDisplay = 10, std::ostream& os = std::cout)
    

    Collects degrees in a vector and presents "top 10" after sorting.

  6. Path_BFS

    Use the following header:

    template < class G >
    bool Path_BFS (const G& g, typename G::Vertex x, typename G::Vertex y, fsu::List<typename G::Vertex>& p)
    

    Applies BFSurvey to graph g, calculates BFS path from x to y and stores result in list p. Uses error stream to report errors, otherwise does no I/O. Returns true/false whether path exists.

  7. Path_DFS

    Use the following header:

    template < class G >
    bool Path_DFS (const G& g, typename G::Vertex x, typename G::Vertex y, fsu::List<typename G::Vertex>& p)
    

    Applies DFSurvey to graph g, calculates DFS path from x to y and stores result in list p. Uses error stream to report errors, otherwise does no I/O. Returns true/false whether path exists.

  8. Postorder

    Use the following header:

    template <class G>
    void Postorder (const fsu::DFSurvey<G>& dfs, std::ostream∓ os)
    

    Prints vertices in finishing order.

  9. log.txt

    In addition to your work log, use this text file to report on testing and other experieneces. Also describe how you chose to visualize the reults of your maze generator/solver system (see hints below).

Hints

Fun with Mazes

Graph Survey Study Experiment Guide