﻿1
00:00:00,500 --> 00:00:04,040
‫So now we're going to create our remove edge function.

2
00:00:04,550 --> 00:00:10,530
‫And as the name would imply, it's just going to remove the connection between two vertices.

3
00:00:10,550 --> 00:00:13,910
‫In the adjacency list it will look like this.

4
00:00:14,510 --> 00:00:21,470
‫So I'm going to move this down and bring that edge back because we haven't removed it yet and start

5
00:00:21,470 --> 00:00:27,950
‫our code like this and we'll pass it to vertices vertex one and vertex two.

6
00:00:28,740 --> 00:00:33,660
‫And we'll say adjacency list at Vertex one.

7
00:00:33,930 --> 00:00:41,100
‫And when we do this, it's going to return the value and the key value pair and the value is going to

8
00:00:41,100 --> 00:00:43,560
‫be this unordered set.

9
00:00:43,860 --> 00:00:52,650
‫And when we return that we can use the member functions on unordered sets and we can say erase vertex

10
00:00:52,650 --> 00:00:58,170
‫two and it removes Vertex two from that unordered set.

11
00:00:58,680 --> 00:01:05,130
‫And then we can do it the other way and remove vertex one like this.

12
00:01:05,580 --> 00:01:10,410
‫And of course, we can only do this if both of the vertices exist.

13
00:01:10,770 --> 00:01:15,420
‫And we'll check to make sure that they both do exist with this if statement.

14
00:01:15,630 --> 00:01:20,370
‫And if they do exist, we'll run those two lines of code and then we'll return.

15
00:01:20,370 --> 00:01:21,150
‫True.

16
00:01:21,480 --> 00:01:26,400
‫If one or both of them do not exist, will return false.

17
00:01:26,910 --> 00:01:30,030
‫So that is our entire remove edge function.

18
00:01:30,030 --> 00:01:37,980
‫We'll look at this code in a moment in vs code and when we do we'll create this graph and then we'll

19
00:01:37,980 --> 00:01:43,230
‫do a remove edge between A and B and then our graph will look like this.

20
00:01:43,710 --> 00:01:47,670
‫So now let's flip over to vs code and take a look at this.

21
00:01:48,430 --> 00:01:55,840
‫So there is our Remove Edge member function that we just created added to our graph class and I'll scroll

22
00:01:55,840 --> 00:01:56,470
‫up.

23
00:01:57,470 --> 00:02:00,710
‫And in our main function this creates our graph.

24
00:02:00,740 --> 00:02:07,850
‫These three lines create those three vertices A, B and C, and these three lines create the edges between

25
00:02:07,850 --> 00:02:08,750
‫all of them.

26
00:02:08,870 --> 00:02:12,950
‫And then with this line will print that out and I'll run this.

27
00:02:13,490 --> 00:02:21,080
‫And you can see we have our three vertices and each of the vertices have edges with the other two vertices.

28
00:02:21,680 --> 00:02:29,000
‫So I'm going to come over here and I'm going to add this line which will remove the edge between A and

29
00:02:29,000 --> 00:02:31,790
‫B, and now I'll run this.

30
00:02:32,550 --> 00:02:37,110
‫And you can see that the edge between A and B has been removed.

31
00:02:38,370 --> 00:02:42,360
‫And that is our function for Remove Edge.

