‫So now we're going to create the ad edge function and ad edge is going to connect to vertices, which
‫in this case will be represented like this.
‫And when we add that edge, we're going to be doing this.
‫So let's put the adjacency list back like this and we'll start writing our function.
‫We'll pass it to vertices vertex one and vertex two.
‫So we're going to say adjacency list at Vertex one and we'll say that Vertex one is a when we do this,
‫it returns the value in the key value pair.
‫So it is returning this unordered set.
‫And because we've returned an unordered set, we can now use the member functions that are associated
‫with unordered sets and we can say dot insert vertex two, which does this, and then we can do the
‫same thing for the other vertex pass that one vertex one which adds a to that unordered set.
‫So we can only do this if the two vertices that were creating an edge between exist.
‫So we'll have this if statement that makes sure that vertex one and vertex two both exist.
‫And if they do, we'll run these two lines of code and the if statement and will return true if one
‫or both of them do not exist.
‫We'll skip the if statement and we'll return false.
‫So that is all of our code for add edge.
‫So now let's flip over to VS Code and take a look at this.
‫So there is our add edge member function added to our graph class and I'll scroll up and in our main
‫function we'll create our graph with this line and that will create our two vertices A and B with these
‫two lines and with this line, we will print that out and I'll run this and you can see that our graph
‫contains those two vertices, but we don't have an edge between them yet, so I'm going to come up here.
‫And I'll add this line, and this adds an edge between A and B.
‫So now I'll run this and you can see that we now have an edge between those vertices and that is our
‫function for ADD Edge.