# INTRODUCTION to GRAPH THEORY – DISCRETE MATHEMATICS  about this Y here ok well why would be a to C so these two are different in this first graph up here with this x and y x and y would both be written just a C and we just have something called a multiplicity of 2 for this so this is multiplicity 2 for a see o should be in sense so sometimes what we’ll do is we’ll just shorten edges so we’ll say that E is just equal to a B and in an undirected graph this is the same thing as BA but in a directed graph order matters so this is not the same thing as ba so sometimes we shorten them so what we’ll do is when we give an example we’ll say it’s an undirected graph or a directed graph or we’ll show a picture with the arrows so those are two types of graphs you need to know proofs for them are always separate so they might have the same proof structure for its properties but they’re always done as separate proofs because they are different objects one has direction one does not okay so here’s another big topic I know we’re going kind of quick but we need to talk about walks and specifically XY walks and a walk in a graph is a sequence of at vertices and edges so it goes vertex edge vertex edge vertex edge and it just follows a path or sorry it follows a walk and it goes from some vertex to another one so here we want to go from X to Y so we take we start at X then we take some edge e1 we go to another vertex v1 we take an edge e 2 we go to some vertex V 2 so on and so forth until we get to Y and of course each edge just consists of the previous vertex and the next vertex so e1 would just be equal to X V 1 e 2 would just be V 1 V 2 so on and so forth so let’s take a look let’s find a walk from A to D so this is how I write the walks and paths so just a arrow D walk so how can we do that well we should probably label these a little bit we’ll call that II 1 we’ll call this e 2 e 3 E 4 E 5 so we start at a and then we take P 1 to be and then ok we could take ‘if I’ve to D and be done or we could take V for to D or we could take e 2 to C and E 3 to D so those are all possible circumstances now what we could do to is take a 2 e 1 or a a and e 1 to B and we could take ye 1 again back to a and then we could take a 1 to B and then e 4 to D because you can go back and forth in your walks that is totally acceptable to go back and forth so walks have no restrictions as long as you follow a vertex and edge a vertex and edge it’s ok in fact when I write out these walks what I’ll do is I won’t give edges names I’ll just say that on a 2d walk is a BD which means you go from A to B to D and the edges are usually obvious if it’s not obvious or I need to specify which edges I’m taking I will give them a label but because it’s not necessary I won’t so a perfectly fine walk would be a b c e f ec b d that is an A to D walk okay so what is a closed walk a closed walk is when you start at a at a vertex X and you get back to the vertex X so it’s the same definition except this Y is actually just X that’s the only difference so if we say I want to walk from E to E as a closed walk so here’s a walk e C D F E that’s a walk or you could have ECE or you could just write E and this is called the trivial walk because it doesn’t take any edges so that is a closed walk so those are walks and a closed walk doesn’t have any fancy name which is called a closed walk now you need to keep this idea separate from the idea of a trail and we’re going to introduce a few different terms here so it’s going to get a little bit confusing because you’re just individually the very simple ideas but the hardest part is separating them in your mind and learning the terminology so a trail is a walk without any repeated edges so for instance let’s label a 1 e 2 e 3 E 4 E but this word there u v e6 and e7 so let’s do a trail from A to F ok so what we can do is we can go from A to D using e to and we can go to be with III C with E 4 and F with E 754 and that is a trail because we didn’t use any edges twice okay what if mm-hmm what can we do here to make this a little bit more interesting not quite sure okay so say we have the path II or the trail or sorry the walk so a lot of terminologies I need to stop myself from saying the wrong words here so we have a trail well a wanting to be trail ECE can we do it back let’s do ECE D okay so we take a six but then we take a six again so because we have e C and C E and these are both taking the same edge this is not a trail so we cannot repeat edges now a closed trail is called a circuit so for instance let’s go from a to a we want to trail from a to a this is called a circuit so we can do a D be a and that’s acceptable but what we can’t do is we can’t do a da that’s not allowed because then we take e to twice so once we use this edge e to we cross it off and then we have to find a new way so let’s say we took E 5 ok well we can’t go back so that means we have to take East 6 ok so we should probably take efore and we could take III but then we’re stuck so we have to take a 1 so that is a circuit does not repeat any edges and starts and ends at the same place so whenever I stay closed what I mean is that X is equal to Y so the start is equal to the end that’s all I’m saying so no repeated edges not bad what do you think’s next a path a path is a walk with no repeated vertices this is why when I use these words like trail path walk I need to be careful with what I say because well they mean different things and colloquially colloquially in English they pretty much mean the same thing when we talk about movement so I need to be careful with this so a path is a walk with no repeated vertices so for instance if we say I want to go from A to E well we can start at a and we can go to B and we can go to D we can go to C and then we can go to E so we could call this a b d c e ok what we can’t do is we can’t say AC b d c e because in this case we have a C here and a C here and that’s not acceptable so we can’t do that path or that walk it’s not a path it’s a lock a closed path is called a cycle so a cycle from A to A could look like a b c a and what you’re saying is hold on a second a is being repeated twice but we don’t count the start in the end to be a repeated vertex if we’re saying i want a path that goes from a to a we say ok the first and the last one can be repeated that’s it so that would be a cycle from a to a so we have a goes to B B goes to C and C goes to a so what we do here when we want to find out our paths or cycles we instead take a look at the vertex and once we get to another vertex for instance let’s say we go to D ok so we circle that and then we say ok now I’m only allowed to go to be C or E so am I going well I can go to e okay cool so we do e and now I can only go to C so we go there and now we take a look at our colored in vertices and we say okay what’s available I can’t I could go to a and end the cycle but I definitely could not go to D because I’ve already used it so ideally actually I’m not getting the color I want okay do this we’ll do this in green because we started here okay so I can’t go to e because we’ve already used E you can repeat edges by the way but that would probably end up with you being at the same vertex so I can’t go to E I can’t go to D my only option left is either A or B so let’s go to B okay so I’m at B now I can’t go to D because we’ve already used it I can’t go back to C but I can finish the cycle and end up at a so then we color an a again and that is a cycle okay so a lot of terminology I know but there’s still one more piece we need to talk about and this is the most intuitive and simple so I left it for last and this is connected graphs the graph is connected if there is an XY path for all XY in the set of vertices so what this means is that if every vertex is connected to every other vertex then the graph is connected if it’s not connected then we take a look at the number of components it has so a component which we call Kappa of G is really just the number of connected graphs or connected sub graphs but we’ll talk about sub graphs next time but this is just the number of connected sub graphs so for instance VA and F are all connected so this whole part is one component this CDE here is just one component and this isolated vertex G is just one component so CDE cannot branch out to anything PAF cannot branch out to anything else and G cannot branch out to anything else so it’s a three component graph so kg is equal to three and here’s the question why does a graph have to be an XY path okay so let’s take a look at the formal definition here so suppose we have three points here and a path has no repeated vertex so you can have something like this something like this something like this something like this and something like this this is a B and C so we can get from B to a and get from B to C you can get from C to a and get from C to B get from A to B and A to C so we’re good here it’s connected what about this case and B okay well we can’t get from A to B so it’s definitely not connected and in fact we can see it’s not connected visually so that’s kind of obvious and here’s another nice example here here’s a and well let’s do this let’s give a one edge it’s clear this cool it’s clearly connected it has one component and there’s a walk from a – a – a – a – a but the reason why we don’t say a walk is because it’s really just unnecessary and I know it’s hard to say like what he just showed us three examples to say is unnecessary well yeah that’s unnecessary because if there is a walk from A to C then clearly there’s a shortest way to get there and why would I go ay-ay-ay see when I could just go a see it’s totally unnecessary or let’s say I want to go from B to C so there’s me to see the quickest way to go is to just put a there so BAC that’s a path no repeated vertex but instead I can go B we can go from B to B and go from a we can go back to B go to a a one more time and then we’ll go to C and that’s just it’s pointless if we told a computer to do this to check to see if a graph is connected it would be useless it wastes so much so much computation in a huge graph to say yeah check all possible ways now we just want to find a path so that’s a theorem maybe we’ll look at is do all connected graphs have a path from A to B fact do all walks from A to E have a path from A to B so for instance here here’s what I want you to do well we’ll visit this later but I want you to prove it now if you can that if there is an XY walk and say for all XY walks for all X I walks there exists an XY path so try to prove that in fact I’m going to give you a hint you’re going to start with a proof by contradiction so you have a proof by contradiction and they’re going to say let W be a minimal we call this a minimal half I’m sorry a minimal path from X to Y okay and then what you’re going to say is actually no let’s just call this a minimal walk from X to Y okay so you have a W it’s going to be a minimal walk from X to Y and this means that this is the shortest the shortest walk from X to Y and there’s going to be two cases case 1 there’s no repeated vertex so what happens in that case tell me what happens in that case and then in case two tell me there’s a repeated vertex V I and in that case what should you do if you get a repeated vertex VI what are you going to do about that well for an example if I have let’s say I have this thing here so this is just on my path some way I’m going to leave or on my walk I’m going to leave this way so what happens is I go from here and then let’s take one down here and I go to here I go to here and then I walk back up top and I continue along my way so should probably do this in different color student this color so when I get to some repeated vertex VI which is this one what should I do about that and if I do something with that what’s the problem so I just underlined a little problem if we have to do anything to that walk and I’m sure you’ll get a nice proof there so honestly if you can prove it leave it in the comments and I will tell you if you’re right because this is a very good exercise and something you would probably see on a midterm ok so that was an impromptu minor tangent let’s do some practice questions on graphs with walks trails and paths so we need to find a walk from B to D that is not a trail so what does a trail a trail has repeated edges so it’s not a trail so we need to have one edge repeat okay so if we want from B to D so we should go from B to E – B to C to D so we went in this manner so we use this edge be e twice therefore it is not a trail because in a trail you cannot reuse edges now let’s go from B to D and with a trail so we can’t repeat edges but it can’t be a path so we so a path repeats no vertices but because it’s not a path we need to repeat a vertex so we start a B let’s go to a so it has to be a trail remember so we go to C and what we need to go to D but we have to repeat a vertex so let’s go back up to be okay so we did be a AC C B then let’s go to E and then let’s go down D so we have B AC B e D so we didn’t use the same edge twice but we used B twice so it’s not a path okay and now let’s find a path from B to D well this is pretty straightforward we go from B to C and then we go from C to D so BCD usually the shortest way is always a path in fact I’m pretty sure if you did my exercise it just gave you you just proved that so let’s go from B to B with a circuit but it can’t be a cycle so what does that mean it means – closed it’s a closed trail that is not a closed path so we we have to only use each edge once but we also have to repeat a vertex somewhere so let’s go from B to a and then a to C now we can’t go back to B because then it would be a cycle so we have to repeat a vertex somewhere so we can’t go back to B so let’s go to D that means we can only go to e I can’t go back to B now because I still haven’t reused a vertex so let’s go from E to G G to F and now we went from F back to G so now we’ve used eat Weiss so it is no longer a path and now we can go back to B we never used the same edge twice so it is a circuit but we hit eat Weiss therefore it is not a cycle so your answer here it’s going to be b a c d e g f e v where e has been used twice and if you take a look at the pair of edges that we use we never use the same one twice so that’s another way of looking at things okay that was one practice problem and the next one is tricky so if G the graph G is a pair of vertices and edges where the cardinality of V is equal to V so this just means the number of vertices and the cardinality of E is equal to little e so this is just the number of edges and we say that G is simple what a simple mean simple is loop free so there’s no loops it is undirected generally it’s undirected and there are no multiple edges so that means that if we have this this is not simple instead this is simple so this is a multi graph and this would be the simple graph so we want to prove that two times the number of edges is going to be less than or equal to the number of vertices squared minus the number of vertices so this is a little bit tricky to think about so here let’s let’s take a look at this graph there’s three vertices so how many possible ways are there to choose edges okay well what is an edge when you take an edge well you take two vertices so they take a and B and you put a line between them okay so how many possible ways can we do that well that’s just V choose to just choose 