CMSC-341 Spring 2001

Project 5

Assigned Monday 30 April, 2001
Preview Sessions Wed 01 May 20001
Thurs 02 May 2001
Due Midnight, Sunday 13 May 2001

Background

Graphs can be applied to many real world applications from computer networks to UPS truck routing and many things in-between.  This project will allow you apply what you've learned about graph implementation and graph related algorithms to solving a real problem.  You will be completing a modified version of exercise 9.45 from the textbook, found on page 384.

Description

    Consider an N x N grid (like a checker board) in which some of the squares are occupied by black circles (representing checkers).  Two squares in the grid belong to the same group if they share a common edge.  Squares are designated by the ordered pair (row, column).  For example, squares (0, 0) and (0,1) are in the same group as are (0, 0) and (1, 0).  However, squares (0, 0) and (1, 1), are not in the same group.  In the figure below, there is one group of four occupied squares, three groups of two occupied squares and two individual occupied squares ("groups" of one).  Your mission is to write a program that does the following:
  1. Opens and reads the grid description file
  2. Creates an appropriate undirected graph representing the occupied squares
  3. Prints the grid in the format specified in the sample output below
  4. Identifies and lists all of the occupied groups in the grid


Project requirements


ADT Descriptions

The Vertex ADT

    Since a vertex may contain data of any kind, your vertex must be a class template.  Your vertex should also hold information (i.e. vertex number) that is internal and known only to the Graph.  You'll find it much easier to use this internal vertex number to identify vertices and edges in the Graph.
    Like List nodes and Tree nodes, the vertices of a graph are only known to and only manipulated by the Graph class. Therefore all data and all methods of the Vertex class must be private.  You make may the Graph a friend of the Vertex for easier coding.  You may create whatever methods and data you feel necessary.

Grid Description File Format

    The grid data file has the following format:
You may assume that all row and column values are valid, but no order is guaranteed.

The grid description file for the figure above can be found in Mr. Frey's public directory
    /afs/umbc.edu/users/d/e/dennis/pub/CMSC341/Proj5
 
 


Sample Output

    The grid should be printed using the following symbols:
    Rows and columns must be labeled and start at zero
    The figure above would be output as

      0 1 2 3 4 5 6 7 8 9
    0 - - - - - - - - - O
    1 - - - O O - - - - O
    2 - - - - - - - - - -
    3 - - - - O - - O - -
    4 - - - O - - - O - -
    5 - - - - - - - O O -
    6 - - - - O O - - - -
    7 - - - - - - - - - -
    8 - - - - - - - - - -
    9 - - - - - - - - - -

    The occupied groups are identified by listing the squares in the group.  For the figure above, the output would be

    Group 1: (0, 9), (1, 9)
    Group 2: (1, 3), (1, 4)
    Group 3: (3, 4)
    Group 4: (4, 3)
    Group 5: (3, 7), (4, 7), (5, 7), (5, 8)
    Group 6: (6, 4), (6, 5)

Your output does not have to be formatted exactly the same, but squares must be designated as (row, column).
Groups may be listed in any order and squares within a group may be listed in any order.


Vector Files

The source code files vector.C and vector.H are available in Mr. Frey's public directory
    /afs/umbc.edu/users/d/e/dennis/pub/CMSC341.
As in earlier projects, DO NOT copy these files to your directory and DO NOT submit the vector files.  Your makefile should specify these files where appropriate.

Files To Be Submitted

You should submit only the files you have written, a makefile, and the file containing your answers to the questions.  The files to be submitted are: If your makefile is set up correctly, you should be able to execute the command make submit.

Questions

Copy the file /afs/umbc.edu/users/d/e/dennis/CMSC341/Proj5/341-Spring01-proj5_questions.txt to your directory, then edit the file to add you answers.  Be sure to submit your file.


 

Grading and Academic Integrity

Project grading is described in the Project Policy handout.

Your answers to 341-Spring01-proj5_questions.txt are worth 10% of your project grade.

Cheating in any form will not be tolerated. Please re-read the Project Policy handout for further details on honesty in doing projects for this course.

Remember, the due date is firm. Submittals made after midnight of the due date will not be accepted. Do not submit any files after that time. 


Last modified on Friday, April 27, 2001 by Dennis Frey

email: frey@cs.umbc.edu