This document is officially released and open for comment.

Project 4: Graph Algorithms

Final Algorithms Project

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

Operational Objectives: Design and implement class ALGraph and one or more graph algorithm classes from this list:

  1. Breadth First Survey
  2. Depth First Survey
  3. Kruskal MST
  4. BFSIterator
  5. DFSIterator (2 flavors)

You may have teams of 1-3 people. Depending on the size of the team, you are required to do 1-3 of the algorithms along with the graph class. So, for example, a team of two people is required to do the ALGraph graph class and two of the algorithms.

Deliverables: Files:

graph.h        # required for all
 fgraph.cpp    # functionality test required for graph.h
bfsurvey.h     # required for a
 fbfsurvey.cpp # functionality test required for bfsurvey.h
dfsurvey.h     # required for b
 fdfsurvey.cpp # functionality test required for dfsurvey.h
kruskal.h      # required for c
 fkruskal.cpp  # functionality test required for kruskal.h
bfsiter.h      # required for d
 fbfsiter.cpp  # functionality test required for bfsiter.h
dfsiter.h      # required for e
 fdfsiter.cpp  # functionality test required for dfsiter.h
readme.txt     # required for all
makefile       # builds all files in project

Procedural Requirements

  1. The official development | testing | assessment environment is gnu g++ on the linprog machines.

  2. Each member of a team submits all team code

  3. The team makup is listed in the file header documentation of each submitted file (see C++ Style link for standards)

  4. File readme.txt explains how the software was developed, what responsibilities each team member had, how it was tested, and how it is expected to be operated.

  5. Copy the file LIB/proj4/proj4submit.sh into your project directory, change its permissions to executable, and submit the project by executing the script.

    Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu 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 - ALGraph

  1. Class ALGraph implements the adjacency list representation of a graph whose vertices are assumed to be unsigned integers 0,1,...,n-1. The interface should conform to:

    namespace fsu
    {
      template < typename N >
      class ALUGraph
      {
      public:
        typedef N      Vertex;
        typedef xxxxx  AdjIterator;
    
        void   SetVrtxSize  (N n);
        void   AddEdge      (Vertex from, Vertex to);
        size_t VrtxSize     () const;
        size_t EdgeSize     () const;
        size_t OutDegree    (Vertex x) const;
        size_t InDegree     (Vertex x) const;
        AdjIterator Begin   (Vertex x) const;
        AdjIterator End     (Vertex x) const;
    
        ALUGraph ( );
        ALUGraph ( N n );
      ...
      };
    } // namespace fsu
    

    where xxxxx is a type that you define. This is an iterator for the adjacency list, which could be fsu::TList<Vertex>::ConstIterator, std::list<Vertex>::const_iterator, or some other type. The directed graph API is exactly the same (but for the name of the class):

    namespace fsu
    {
      template < typename N >
      class ALDGraph
      {
      public:
        typedef N      Vertex;
        typedef xxxxx  AdjIterator;
    
        void   SetVrtxSize  (N n);
        void   AddEdge      (Vertex from, Vertex to);
        size_t VrtxSize     () const;
        size_t EdgeSize     () const;
        size_t OutDegree    (Vertex x) const;
        size_t InDegree     (Vertex x) const;
        AdjIterator Begin   (Vertex x) const;
        AdjIterator End     (Vertex x) const;
    
        ALUGraph ( );
        ALUGraph ( N n );
      ...
      };
    } // namespace fsu
    

    Much of the implementation code for the undirected and directed cases is identical, so it can be profitable to derive one of these from the other. In the derived class, only AddEdge, EdgeSize, and InDegree require re-definition.

  2. Begin(x) returns an AdjIterator which is a forward ConstIterator that iterates through the adjacency list of the vertex v. End(x) returns the end iterator of the adjacency list. So, the loop

    for (typename GraphType::AdjIterator i = g.Begin(x); i != g.End(x); ++i)
    {/*   do something at the vertex *i   */}
    

    encounters all of the vertices adjacent from v in the (directed or undirected) graph g.

  3. The template argument is some unsigned integer type. We are using templates mainly as a convenience so that member functions will not be compiled (or even require implementation) if they are not called by client code.

Code Requirements and Specifications - Algorithms

  1. Algorithms should operate on ALGraph objects via the interface defined above, so that another team's version of ALGraph can be substituted without modification.

  2. Algorithms should be class templates (in line with the graph class template). See discussion of algorithm classes in the Graphs 1 Lecture Notes.

Code Requirements and Specifications - Test Code

  1. For ALGraph and each algorithm implemented by your team, a functionality test/demo client program should be created in the file fxxx.cpp, where xxx.h is the file holding the class being tested.

  2. All graph and algorithm code should be tested thoroughly. Test code should be developed concurrently with the classes and a test plan should be agreed to and adhered to. The tests, test results, and general development plan should be documented in the text file readme.txt.

  3. Your test programs should work with graphs defined in files using the format illustrated in the distributed data files. The file may begin with optional documentation - lines beginning with # are ignored. After the file documentation, there should be nothing but unsigned integer numbers in decimal notation. The first number is the number of vertices. Then the edges follow, one at a time, consisting of the from vertex followed by the to vertex. (Do not list an edge twice for an undirected graph.) For example:

    #
    # file graph1.10.10
    #
    # This is the graph G1                   0 --- 1     2 --- 6 --- 7
    # depicted to the right                  |           |           |
    #                                        |           |           |
    # G1 has 10 vertices                     3 --- 4 --- 5 --- 8 --- 9 
    # G1 has 10 edges                                Graph G1
    
    10
    0 1 0 3
    2 5 2 6
    3 4
    4 5
    5 8
    6 7
    7 9
    8 9
    

    This file represents the graph G1 from the Graphs 1 lecture notes. Note that each edge is listed only one time, and both ends of each edge are given. Several other graph files are distributed and should be used in your testing, along with any others you may deem appropriate. The format and order of the edge information should not matter to your test code, but it is nice for human readability. For example, the following file specifies the same undirected graph G1:

    10 4 3 5 4 7 9 1 0 2 5 6 2 0 3 6 7 8 9 5 8
    

    10 for the number of vertices, followed by the ten specified undirected edges. (Note this specifies a different directed graph, because some of the edges are listed in opposit direction.) This alternate representation is in file graph2.10.10.

  4. The single command "make" should build all test and demo executables for your project, requiring ONLY the course library, the standard library, and your submitted files. You should test this by copying only your submit files to a separate directory and entering "make".

Hints