A2 - CMPT 225 D1 - Fall 2010 - Assignment 2 (7%) Submit...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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....
View Full Document

Page1 / 3

A2 - CMPT 225 D1 - Fall 2010 - Assignment 2 (7%) Submit...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online