Create the following graph. Implement the following functions. 1. addEdge() that takes two vertices as two parameters and creates an Edge between them. 2. nonAdjacentVertices() that takes a single vertex as parameter, and returns an array of vertices that are NOT adjacent to that vertex. 3. Write a function addUnknownVertices() that takes a vertex as a parameters, and creates an Edge with the vertices that are NOT adjacent to it. 4. Write a method searchVertex() which takes an array of Vertices as parameters. The first member of the array will be the starting vertex and the last member will be the Vertex you want to reach. For example searchVertex(Vertex 0, Vertex 4, Vertex 3) will output “Vertex cannot be reached” since you can reach from 0 to 4, but cannot from 4 to 3. Again, searchVertex(Vertex 0, Vertex 1, Vertex 2, Node 3) will output “Vertex can be reached” since you can reach from 0 to 1, 1 to 2, 2 to 3.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Create the following graph. Implement the following functions.

1. addEdge() that takes two vertices as two parameters and creates an Edge between them.

2. nonAdjacentVertices() that takes a single vertex as parameter, and returns an array of vertices that are NOT adjacent to that vertex.

3. Write a function addUnknownVertices() that takes a vertex as a parameters, and creates an Edge with the vertices that are NOT adjacent to it.

4. Write a method searchVertex() which takes an array of Vertices as parameters. The first member of the array will be the starting vertex and the last member will be the Vertex you want to reach. For example searchVertex(Vertex 0, Vertex 4, Vertex 3) will output “Vertex cannot be reached” since you can reach from 0 to 4, but cannot from 4 to 3. Again, searchVertex(Vertex 0, Vertex 1, Vertex 2, Node 3) will output “Vertex can be reached” since you can reach from 0 to 1, 1 to 2, 2 to 3.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning