Question: Create an application in C + + called main.cpp that , given a directed graph without cycles ( DAG ) , with n vertices

Create an application in C++called "main.cpp"that, given a directed graph without cycles(DAG),with n vertices and frames, says whether the graph is a tree and displays its topological order. Use the following functions
loadGraph
Description: Load the edges of the graph and store them in an Adjacency List
Input: Two positive integers:
-n(Number of Vertices)
-m(Number of Arcs)
2*m "letters" representing start and end of each arc, two per line
(start and end of each arc)
Output: Nothing
Precondition: n and m are positive integers
Postcondition: Nothing
isTree
Description: Tell whether the Directed Graph(DAG)is a tree or not
Input: The Adjacency list, n(Vertices)and m(Arcs)(pointer)
Output: A boolean value telling whether the graph is a tree or not.
Precondition: The graph must be correctly loaded in the adjacency list, n and m must be positive integers.
Postcondition: Nothing
topologicalSort
Description: Sort the nodes of the DAG using Kahn's algorithm
Input: The adjacency list, n(Vertices)and m(Arcs)(pointer)
Output: Nothing
Precondition: The graph must be correctly loaded in the adjacency list, n and m must be positive integers.
Postcondition: Nothing
The input to the program is the number of vertices(n),the number of arcs(m)as well as each of the arcs.
The output is,first a boolean(true|false)that tells whether the graph is a tree or not, followed by the topological sort of the DAG(following Kahn's algorithm)writing one node at a time, followed by a space. After the last node, there is also a blank space and a line break at the end
Input example:
13
18
A D
B D
C A
C B
D G
D H
E A
E D
E F
F J
F K
G I
H I
H J
I L
J L
J M
K J
Output example:
false
C E B A F D K G H I J L M
All the functionalities must be correctly aligned and documented.
As part of the documentation, the complexity of each one of them must be included.
The application must request the user for the number of vertices(n),the number of nodes(m)as well as each of the arcs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!