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

Create a C++ application called "main.cpp" that, given a directed graph without cycles (DAG), with n vertices and frames, tells whether the graph is a tree and displays its topological order.
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 newline 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
Important.
This should only be done with libraries.
#include
#include
#include
DO NOT USE ANYTHING WITH DIFFERENT LIBRARIES.

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!