Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

COEN 244 (Summer XXXXXXXXXXAssignment 3 Group Assignment (1 or 2 members) Submission The submission must be through Moodle on the submission link for Programming Assignment 1. Email submissions will...

1 answer below »

COEN 244 (Summer XXXXXXXXXXAssignment 3
Group Assignment (1 or 2 members)

Submission
The submission must be through Moodle on the submission link for Programming Assignment
1. Email submissions will NOT be accepted. The assignment must be done individually. All
cases of plagiarism will be reported to authorities as per Concordia’s plagiarism policy.

Create [SID_1]_[SID_2]_A3.zip (.gz, .tar, .zip are acceptable. .rar file is NOT acceptable)
file contains a folder named with your student ID. This folder contains all the source code
only for the assignment. Submissions do not follow the format may not be graded.


Problem statement
This assignment aims to practice operator overloading. The operator overloading techniques
are applied to graph operations. The graph has the same definition as Assignment 2 as
presented as follows:

A Graph is formally defined as G=(N,E), consisting of the set V of vertices (or nodes) and
the set E of edges, which are ordered pairs of the starting vertex and the ending vertex.
Each vertex has ID and value as its basic attributes. Each edge has weight, starting vertex
and ending vertex.

A Graph can be a directed graph and undirected graph. A Directed Acyclic Graph (DAG) is
a finite directed graph with directed cycles. This means from any vertex v, there is no way to
follow a sequence of edge that eventually loops back to v again. An undirected graph (UG)
is a graph where the edges are bidirectional. Please define either the class DAG or the class
UG as derived class from the class Graph.

In this assignment, the tasks are operator overloading. Suppose g1, g2, and g3 are objects
of the graph class as you define, the illustrating examples and semantic meaning of each
operator are presented as shown in the table below.
Definition Example
1. operator == returns true if g1 and g2 have exactly the same
vertices and edges
if(g1 == g2){
…
}
1. operator = assigns g2 to g1. g1 = g2;
2. operator++ in both prefix and postfix increase the weights of all
edges by one.
g1++;
++g1;
3. operator+ returns a graph that contains all the nodes of g1 and
g2, and all the edges of g1 and g2.
g3 = g1+ g2;
4. operator[ ] returns the vertex at the index position or update the
value at the index position. (hint: make sure that the Vertex
class should overload the assignment operator= )
Vertex v1 = g1[0];
Vertex v2;
g1[2] = v2;
5. operato
outputs a graph with all the edges at the format that
you can define.
cout
g1
endl;
6. operator string() casts the graph object to a string that encodes
all the edges.
String s =
(string)g1;

Problem 1: please define each operator overloading function in the graph header file (10
points) and program the implementation of each operator in the graph .cpp file. (10 points for
each operator. ++ prefix and ++ postfix are two operators)

Problem 2:
Create a driver class with the main function to test each operator. Each test should be
programmed in a test function. The main function calls each test function. (Each test function is 5
points).




Answered 1 days After Aug 06, 2022

Solution

Ruchi answered on Aug 08 2022
74 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here