{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# A2 - CMPT 225 D1 Fall 2010 Assignment 2(7 Submit your...

This preview shows pages 1–2. Sign up to view the full content.

CMPT 225 D1 - Fall 2010 - Assignment 2 (7%) Submit your solutions online by 5:00 pm, Thursday, Oct. 21, 2010. 1. [40 marks] Implement a C++ Graph Class Implement a C++ class iGraph with the following public functions: iGraph(int m) Constructor. It creates a new iGraph instance which represents a graph with no vertices and no edges, and has the capacity for up to m vertices. The assumption is that all vertices in the graph will be int values in the range 1 . . . m . int max vertex() Returns the maximum int that can be used as a vertex (which is also the maximum number of vertices). bool has vertex( int v) Returns true iff v is a vertex of the graph. void add vertex( int v) Adds v to the set of vertices of the graph. void add edge( int u, int v) Adds ( u, v ) to the set of edges of the graph. bool has edge( int u, int v) Returns true iff ( u, v ) is an edge of the graph. void mark vertex( int v) Marks vertex v . void unmark all vertices() Unmarks all vertices. bool is marked(int v) Returns true iff vertex v is marked. int number of vertices() Returns the number of vertices of the graph. int number of edges() Returns the number of edges of the graph. bfs(int v) Executes a breadth-first search starting at vertex v , marking all vertices visited. It does not un-mark any vertex, and does not mark any vertex not visited. ~ iGraph() Destructor. You may implement it any way you like, consistent with the following: (a) You may not make any changes to these prototypes for the public methods; (b) You must implement it yourself, from scratch. That is, you may not implement it by “embedding” some existing graph class, you must use your own queue implementation, you must code your own data structure for storing edges, and you may not use vectors or other container-like library classes.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern