<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Graphs Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/category/graphs/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/category/graphs/</link>
	<description></description>
	<lastBuildDate>Sat, 15 Aug 2026 13:59:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>Graphs Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/category/graphs/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Represent an Unweighted Undirected Graph with an Edge List</title>
		<link>https://www.NeuralLantern.com/how-to-represent-an-unweighted-undirected-graph-with-an-edge-list/</link>
					<comments>https://www.NeuralLantern.com/how-to-represent-an-unweighted-undirected-graph-with-an-edge-list/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sat, 15 Aug 2026 13:59:02 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[adjacency alternative]]></category>
		<category><![CDATA[coding graphs]]></category>
		<category><![CDATA[constant time lookup]]></category>
		<category><![CDATA[edge list]]></category>
		<category><![CDATA[edge tuples]]></category>
		<category><![CDATA[graph algorithms]]></category>
		<category><![CDATA[graph data structure]]></category>
		<category><![CDATA[graph representation]]></category>
		<category><![CDATA[graph theory basics]]></category>
		<category><![CDATA[index based edges]]></category>
		<category><![CDATA[node list]]></category>
		<category><![CDATA[undirected graph]]></category>
		<category><![CDATA[undirected unweighted]]></category>
		<category><![CDATA[unweighted graph]]></category>
		<category><![CDATA[vertex list]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=424</guid>

					<description><![CDATA[<p>Represent an unweighted undirected graph as a tuple of a vertex list and an edge list. Store nodes as indexable objects and list each edge once as a pair of indexes so you can reach any vertex in constant time.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-represent-an-unweighted-undirected-graph-with-an-edge-list/">How to Represent an Unweighted Undirected Graph with an Edge List</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How to Represent an Unweighted Undirected Graph with an Edge List" width="1380" height="776" src="https://www.youtube.com/embed/eIBfYgU1QIk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Learn how to represent an unweighted undirected graph using an edge list. We build a sample graph with nodes and edges, then show the vertex list and edge list as tuples. See why storing indexes instead of node values makes lookups faster in constant time. Follow along as we list every connection without duplicates. This is the first in a series covering all four combinations of weighted and directed graphs with edge lists.</p>



<p class="wp-block-paragraph">00:00 Introduction to Edge List Representation<br>00:56 Drawing a Sample Graph with Nodes<br>02:05 Adding Undirected Unweighted Edges<br>03:10 Graph as a Tuple of Vertex and Edge Lists<br>03:40 Building the Vertex List<br>04:24 Storing Nodes as Objects with Indexes<br>06:13 Creating the Edge List of Tuples<br>07:00 Listing Edges by Node Values<br>11:36 Limitations of Storing Node Values<br>12:30 Switching to Index-Based Edge List<br>14:08 Constant-Time Lookups with Indexes<br>16:54 Summary of the Edge List Method<br>17:16 Preview of Next Videos in the Series<br>17:44 Closing Remarks and Subscribe Request</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p class="wp-block-paragraph">Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hello there! Let&#8217;s talk about representing an unweighted,</p>



<p class="wp-block-paragraph">undirected graph in your machine using an edge list representation.</p>



<p class="wp-block-paragraph">Okay, so hopefully you watched my previous videos. If you haven&#8217;t, you might want to take a step back</p>



<p class="wp-block-paragraph">and check them out. We talked about, you know, what is a graph? What are some basic rules and</p>



<p class="wp-block-paragraph">terminology of a graph? Not graph and paper, but a graph. And we talked about representing paths</p>



<p class="wp-block-paragraph">in graphs.</p>



<p class="wp-block-paragraph">representing paths in graphs using either a list of nodes or a list of edges and we&#8217;re going to</p>



<p class="wp-block-paragraph">take the edge list concept one step further and we&#8217;re going to actually just say this whole graph</p>



<p class="wp-block-paragraph">is being represented as an edge list it&#8217;ll make sense in a little bit but uh so the first thing</p>



<p class="wp-block-paragraph">i&#8217;m going to do is try to set up my stuff which is always set up wrong because i&#8217;m the one setting it</p>



<p class="wp-block-paragraph">up and it always gets messed up okay so i got a graph paper and uh oh i got to make this other</p>



<p class="wp-block-paragraph">thing full screen. Sorry.</p>



<p class="wp-block-paragraph">um i&#8217;m going to draw a random graph just real fast so i&#8217;m going to do i don&#8217;t know just some random</p>



<p class="wp-block-paragraph">nodes so remember a graph is a collection of nodes and edges doesn&#8217;t even have to have edges but you</p>



<p class="wp-block-paragraph">know we&#8217;ll just say so we&#8217;re going to do that&#8217;s bad let me try one more time we&#8217;ll get that okay</p>



<p class="wp-block-paragraph">so we get i&#8217;m trying to get this circle perfect because i&#8217;m gonna have to duplicate it rare okay</p>



<p class="wp-block-paragraph">i&#8217;ve got a node here and i&#8217;m just going to give it an arbitrary value i&#8217;m going to say it&#8217;s got a 3</p>



<p class="wp-block-paragraph">and then i&#8217;m going to duplicate it a few times just to make a graph that is a little bit</p>



<p class="wp-block-paragraph">interesting so we have something uh something to kind of challenge us i guess so it&#8217;s not</p>



<p class="wp-block-paragraph">incredibly boring um and then i&#8217;m going to change some of the values here and then well i&#8217;ll change</p>



<p class="wp-block-paragraph">the next ones and then we&#8217;ll start looking at edges which edges do we want to make okay so</p>



<p class="wp-block-paragraph">right now we&#8217;re just making a graph make this graph along with me if you want to or uh you</p>



<p class="wp-block-paragraph">you know, after you.</p>



<p class="wp-block-paragraph">to or uh you know after you think you understand do another graph on your own</p>



<p class="wp-block-paragraph">okay so i&#8217;m gonna make some edges right now remember this is going to be an undirected</p>



<p class="wp-block-paragraph">unweighted graph so the edges are just going to be lines they&#8217;re not going to have direction on</p>



<p class="wp-block-paragraph">them and they&#8217;re not going to have weights on them i&#8217;m going to do a line over here i&#8217;m just</p>



<p class="wp-block-paragraph">randomly doing lines doesn&#8217;t really matter um what we do exactly the point is going to be let&#8217;s</p>



<p class="wp-block-paragraph">practice represented</p>



<p class="wp-block-paragraph">be let&#8217;s practice representing this graph okay so i&#8217;m just making a random graph it&#8217;s kind of like</p>



<p class="wp-block-paragraph">a little bit dense i don&#8217;t know um maybe i&#8217;ll just stop there and then i&#8217;ll add a wonky line just</p>



<p class="wp-block-paragraph">just to prove we can be cool about this i don&#8217;t know we&#8217;ll do another one right here so it&#8217;s a</p>



<p class="wp-block-paragraph">slightly more interesting graph okay so um that&#8217;s just a graph and uh what i&#8217;m going to do is i&#8217;m</p>



<p class="wp-block-paragraph">going to say this is a, you know, an unweighted, oops, weighted.</p>



<p class="wp-block-paragraph">oops waited undirected uh graph and we&#8217;re going to use the edge list of representation</p>



<p class="wp-block-paragraph">i have spell check on this i really hope i do nope okay i guess i forgot to fix that months ago</p>



<p class="wp-block-paragraph">all right so then the next thing we&#8217;re going to do is uh we&#8217;re going to look at the idea of like</p>



<p class="wp-block-paragraph">how do we start with the edge list representation okay um the first thing i&#8217;m going to say is that</p>



<p class="wp-block-paragraph">our graph</p>



<p class="wp-block-paragraph">that the our graph in an edge list representation is a tuple just meaning it&#8217;s you know some things</p>



<p class="wp-block-paragraph">put together if you know tuples encoding already uh the tuple is going to consist of a collection</p>



<p class="wp-block-paragraph">of vertices and edges what&#8217;s going to be an edge list don&#8217;t make fun of my ease please</p>



<p class="wp-block-paragraph">anyway so uh let&#8217;s do the first thing is going to be the vertex list so how do we represent the</p>



<p class="wp-block-paragraph">vertex list or the node list well i&#8217;m just going to say that my vertex list v</p>



<p class="wp-block-paragraph">to say that my vertex list v is equal to something and we&#8217;ll just put inside of this</p>



<p class="wp-block-paragraph">some vertices so the easiest way when you&#8217;re kind of drawing this right now is i&#8217;m just going to</p>



<p class="wp-block-paragraph">start putting the values of the node i&#8217;m going to say well here&#8217;s a three and uh i guess i could</p>



<p class="wp-block-paragraph">sort them for whatever reason uh if we&#8217;re going to do binary search on them later but we&#8217;re not</p>



<p class="wp-block-paragraph">going to i&#8217;m just going to maybe you know what i&#8217;ll go from left to right so that&#8217;ll make more</p>



<p class="wp-block-paragraph">sense, just visually. So I&#8217;ll go from left to right. 3, 13, 6, 12.</p>



<p class="wp-block-paragraph">3, 13, 6, 12, and a 15, and an 18.</p>



<p class="wp-block-paragraph">You can see all of those are nodes, right?</p>



<p class="wp-block-paragraph">Somebody stop me if I forgot a node.</p>



<p class="wp-block-paragraph">Okay, here&#8217;s the thing though.</p>



<p class="wp-block-paragraph">What are we actually storing in this vertex list?</p>



<p class="wp-block-paragraph">You probably don&#8217;t want to store the node values.</p>



<p class="wp-block-paragraph">I mean, you could be a little slow and dumb though,</p>



<p class="wp-block-paragraph">but we want the option to be a little bit faster later</p>



<p class="wp-block-paragraph">and also the option to turn these vertices into full classes,</p>



<p class="wp-block-paragraph">like give them extra properties and whatever.</p>



<p class="wp-block-paragraph">So what I&#8217;m going to say is that…</p>



<p class="wp-block-paragraph">So what I&#8217;m going to say is that I&#8217;m writing down the number 3 and the number 13 here for you, but you should imagine in your code you would have an object of type vertex or node, like a full class, and you would basically be stuffing pointers inside of that vector, inside of that list.</p>



<p class="wp-block-paragraph">I keep saying list. It is called an edge list representation, but you can probably imagine</p>



<p class="wp-block-paragraph">that this could just as easily be a vector. If you&#8217;ve seen my other videos, you know what that is.</p>



<p class="wp-block-paragraph">but uh so i want to be able to index this uh faster so for me personally i make this a vector</p>



<p class="wp-block-paragraph">and not an actual list but we&#8217;re going to call it a list anyway so three should be a pointer</p>



<p class="wp-block-paragraph">uh to a full node object uh smart pointer raw pointer whatever you want 13 should be a full</p>



<p class="wp-block-paragraph">pointer to an entire uh entirely different node object with just 13 assigned as its uh template</p>



<p class="wp-block-paragraph">type value because we&#8217;re making this a vector we can actually index</p>



<p class="wp-block-paragraph">can actually index uh the nodes right so like this is like index 0 for the 3 node index 1 for the 13</p>



<p class="wp-block-paragraph">node so i&#8217;m just going to put the indexes here whoops just to drive the point home a little</p>



<p class="wp-block-paragraph">bit further so if i told you hey let&#8217;s do uh the node at index 2 you would know that is the node</p>



<p class="wp-block-paragraph">that is in the very middle with the value of 6 because index 0 and 1 and 2 brings you to this</p>



<p class="wp-block-paragraph">node right here um which is a 6 so this is going to this is going to help us later let me save this</p>



<p class="wp-block-paragraph">Real fast, by the way.</p>



<p class="wp-block-paragraph">let me save this real fast by the way i&#8217;m just going to do that okay so uh the next thing that</p>



<p class="wp-block-paragraph">we need to do is uh make an edge list the edge list is really where it&#8217;s all at that&#8217;s really</p>



<p class="wp-block-paragraph">where all the data is it&#8217;s going to tell us exactly where everything is or it&#8217;s going to</p>



<p class="wp-block-paragraph">describe the whole graph pretty much so the edge list is another we&#8217;ll say that&#8217;s a list this could</p>



<p class="wp-block-paragraph">be like a linked list or vector or whatever you want i&#8217;m just going to say it&#8217;s a linked list</p>



<p class="wp-block-paragraph">and every item in the list is going to be another tuple so remember above the graph itself was a</p>



<p class="wp-block-paragraph">tuple containing a vertex list and an edge list so the edge list is a list of tuples</p>



<p class="wp-block-paragraph">meaning you know items bundled together for one tuple and then just like a list of those</p>



<p class="wp-block-paragraph">so what i&#8217;m going to try to do is describe every single edge uh one by one using one tuple each</p>



<p class="wp-block-paragraph">inside of the edge list so the first thing i&#8217;m going to do just you know to make this a little</p>



<p class="wp-block-paragraph">little bit easier.</p>



<p class="wp-block-paragraph">thing I want to do just you know to make this a little bit easier is I&#8217;m going to ignore the</p>



<p class="wp-block-paragraph">indexes for the vertex list and I&#8217;m going to say let&#8217;s describe everything happening from the three</p>



<p class="wp-block-paragraph">node outwards or just to every other node so the three node itself I&#8217;m going to look at its</p>



<p class="wp-block-paragraph">connections from left to right so the three node let&#8217;s just start by putting a three here</p>



<p class="wp-block-paragraph">maybe I should describe the legend real fast the tuples will basically be the start node</p>



<p class="wp-block-paragraph">and then the end node</p>



<p class="wp-block-paragraph">and then the end node and then the uh well the weight if there was a weight but we&#8217;re doing an</p>



<p class="wp-block-paragraph">unweighted graph so it&#8217;s really just going to be a tuple of two items the other thing to keep</p>



<p class="wp-block-paragraph">in mind is that because this is an undirected graph it really doesn&#8217;t make a difference what</p>



<p class="wp-block-paragraph">node is the start node and what node is the end node you can just swap them and it&#8217;s totally fine</p>



<p class="wp-block-paragraph">for me personally i&#8217;d rather you know sort before assigning the start node and end node that way</p>



<p class="wp-block-paragraph">when i read the graph later it&#8217;s a little bit faster because i wouldn&#8217;t have to check in both</p>



<p class="wp-block-paragraph">directions but</p>



<p class="wp-block-paragraph">wouldn&#8217;t have to check in both directions but it really honestly doesn&#8217;t matter right now so</p>



<p class="wp-block-paragraph">start node and end node so the start node here is 3 and the end node is going to be 13 so that&#8217;s the</p>



<p class="wp-block-paragraph">first thing that we&#8217;re doing that&#8217;s the first tuple and then i&#8217;m going to say what else does</p>



<p class="wp-block-paragraph">the 3 connect to it connects to the not the 6 it connects to the 12. okay so the 3 connects to the</p>



<ol start="12" class="wp-block-list">
<li>again we could have said 12 comma 3 wouldn&#8217;t have mattered but i&#8217;m just going to try to keep</li>
</ol>



<p class="wp-block-paragraph">it sorted so then</p>



<p class="wp-block-paragraph">keep it sorted so then what else does the three connect to it connects to the uh the 18 doesn&#8217;t</p>



<p class="wp-block-paragraph">connect to the 15 and just confirm that if i&#8217;m looking at the three i can see three lines</p>



<p class="wp-block-paragraph">touching it so that means okay there&#8217;s got to be three tuples for the for the e for the three so</p>



<p class="wp-block-paragraph">i&#8217;m going to say three connects to the 18. and now i&#8217;ve described everything happened to do with the</p>



<p class="wp-block-paragraph">three note i will simply continue let&#8217;s see should i do like a new line maybe i should try to do a</p>



<p class="wp-block-paragraph">new line for every</p>



<p class="wp-block-paragraph">try to do a new line for every start node so this is easier to look at okay so i&#8217;m going to do that</p>



<p class="wp-block-paragraph">and i&#8217;m going to say the next line is we&#8217;ll start at the 13 this time so the 13 the 13 is also</p>



<p class="wp-block-paragraph">connected to the 3 because it goes in both directions with an undirected graph but we</p>



<p class="wp-block-paragraph">already described that connection with that first row so 3 comma 13 describes 13 comma 3 i don&#8217;t</p>



<p class="wp-block-paragraph">want to duplicate edges so forget about that let&#8217;s look at what else 13 is connected to it&#8217;s connected</p>



<p class="wp-block-paragraph">it to the six</p>



<p class="wp-block-paragraph">connected to it&#8217;s connected to the six so I&#8217;m just going to put 13 comma 6 and then that&#8217;s the end of</p>



<p class="wp-block-paragraph">the 13&#8217;s connections oh I could have used tabs for that hang on let me do that okay so now let&#8217;s look</p>



<p class="wp-block-paragraph">at the six node six is not connected to the three it is connected to the 13 but we already described</p>



<p class="wp-block-paragraph">the 13 6 connection in the previous row so forget that and then I&#8217;m just going to look to the right</p>



<p class="wp-block-paragraph">So the 6 is connected to the 12 and the 15.</p>



<p class="wp-block-paragraph">the 12 and the 15 12 and the 15 and also the 18 so i&#8217;m going to do 6 comma 12 maybe i&#8217;m going to</p>



<p class="wp-block-paragraph">do a copy paste here real fast just to make it easier 6 12 and 6 15 and 6 18 so again all i&#8217;m</p>



<p class="wp-block-paragraph">doing is describing you know what other nodes the current node is touching and i&#8217;m going to do that</p>



<p class="wp-block-paragraph">using a tuple that just has one node and has another node and that&#8217;s pretty much it so when</p>



<p class="wp-block-paragraph">we&#8217;re done with this</p>



<p class="wp-block-paragraph">it so when we&#8217;re done with this uh we&#8217;re going to look at the 12 node 12 node it&#8217;s connected to</p>



<p class="wp-block-paragraph">the six already handled it&#8217;s connected to the three it&#8217;s already handled and it&#8217;s connected</p>



<p class="wp-block-paragraph">to the 18 not handled yet so i&#8217;m going to say 12 goes out to 18. okay then we&#8217;re going to look at</p>



<p class="wp-block-paragraph">the 15 node 15 and 6 that&#8217;s already handled in that third row so forget that 15 and 18 that is</p>



<p class="wp-block-paragraph">is not</p>



<p class="wp-block-paragraph">15 and 18 that is not handled yet so we&#8217;re going to do 15.18 by the way this is one benefit of</p>



<p class="wp-block-paragraph">going from left to right visually all i really have to do is just look my eyes to the right and</p>



<p class="wp-block-paragraph">i&#8217;ll see nodes that i need to take care of and if i look my eyes to the left i&#8217;ll see nodes that i</p>



<p class="wp-block-paragraph">already took care of if that makes sense so now that we&#8217;re done with the 15 let&#8217;s see we did 3 13</p>



<p class="wp-block-paragraph">6 12 15 let&#8217;s just take care of the 18 if there&#8217;s anything left to take care of i can guarantee</p>



<p class="wp-block-paragraph">there&#8217;s not going to be.</p>



<p class="wp-block-paragraph">there&#8217;s not going to be because every node the 18 is the node on the farthest you know the furthest</p>



<p class="wp-block-paragraph">to the right so everything on the left is already handled so we don&#8217;t even have to put anything for</p>



<p class="wp-block-paragraph">the 18 node okay give me a second to clean up this graph real fast i think i want to maybe</p>



<p class="wp-block-paragraph">move this up a little bit okay uh now here&#8217;s the thing though we&#8217;ve only named node values so if</p>



<p class="wp-block-paragraph">we wanted to i don&#8217;t know let&#8217;s say check to see if the uh let&#8217;s say we have an edge we&#8217;re looking</p>



<p class="wp-block-paragraph">Thank you.</p>



<p class="wp-block-paragraph">let&#8217;s say we have an edge we&#8217;re looking at the 3 comma 13 edge and we&#8217;re asking now do both of</p>



<p class="wp-block-paragraph">those nodes exist the edge describes these two nodes do they exist or uh maybe let&#8217;s look at</p>



<p class="wp-block-paragraph">the three here and we want to figure out just you know what other nodes does three touch so we start</p>



<p class="wp-block-paragraph">iterating through all the edges here how can we actually get a pointer to that node to manipulate</p>



<p class="wp-block-paragraph">it in the code right now it&#8217;s okay because it&#8217;s a diagram but you know this is not very</p>



<p class="wp-block-paragraph">diagram but you know this is not very good storing values directly in this notation in your code you</p>



<p class="wp-block-paragraph">probably want to store pointer uh pointers there but maybe not necessarily smart pointers they take</p>



<p class="wp-block-paragraph">a little bit of extra memory and it&#8217;s kind of cumbersome but um we could store an index into</p>



<p class="wp-block-paragraph">this vertex list to make things a little bit faster let me show you what i mean but first i&#8217;m</p>



<p class="wp-block-paragraph">going to duplicate this list that we just made already, duplicate it over here, and</p>



<p class="wp-block-paragraph">over here and maybe i&#8217;ll label the first one and i&#8217;ll say so we already have start node and end</p>



<p class="wp-block-paragraph">node i&#8217;m going to say e underscore by value so we&#8217;re storing the edge list by node values and</p>



<p class="wp-block-paragraph">then here we&#8217;re going to store nodes by their index in the vertex list so what do i mean by</p>



<p class="wp-block-paragraph">index well okay right here the first node that we&#8217;re mentioning is the three well look at the</p>



<p class="wp-block-paragraph">three node in the vertex list it&#8217;s at index zero right so i&#8217;m just going to put a zero</p>



<p class="wp-block-paragraph">zero right so i&#8217;m just gonna put a zero that&#8217;s it change it to an index then i look at the 13</p>



<p class="wp-block-paragraph">that&#8217;s index one and then i look at the three again that&#8217;s index zero um and then the 12 is</p>



<p class="wp-block-paragraph">index three and then the three again is index zero and the 18 is index five um if that was too fast</p>



<p class="wp-block-paragraph">i&#8217;m sorry just rewind and play it back in slow motion i think this video is already getting way</p>



<p class="wp-block-paragraph">too long so then i do the same thing for every single other tuple so the 13 node um that is</p>



<p class="wp-block-paragraph">node um that is index one so i&#8217;m going to put a one there the sixth node is index two go on to</p>



<p class="wp-block-paragraph">the next node so the sixth node is index two and then the 12 is index three and the six is two and</p>



<p class="wp-block-paragraph">the 15 is actually four the six again is two the 18 is five move on to the 12 node here uh that&#8217;s</p>



<p class="wp-block-paragraph">index 3, 18 node is index 5, and then</p>



<p class="wp-block-paragraph">the 15</p>



<p class="wp-block-paragraph">and then uh the 15 is index 4 and then 18 again is index 5 so now on you know on both sides like</p>



<p class="wp-block-paragraph">in both of these edge lists uh i&#8217;m representing the graph it&#8217;s just that one can be a little bit</p>



<p class="wp-block-paragraph">more efficient than the other uh for example if i was going to let&#8217;s just say i wanted to scan</p>



<p class="wp-block-paragraph">every single edge in the graph well i could scan this list right here in linear time so linear time</p>



<p class="wp-block-paragraph">based on the number of edges and every single time i see an edge i can jump directly to the</p>



<p class="wp-block-paragraph">Corresponding.</p>



<p class="wp-block-paragraph">jump directly to the corresponding vertex or node in constant time because i have an index</p>



<p class="wp-block-paragraph">so for example let&#8217;s say uh you know this uh the sixth node um touching the 15 node so that</p>



<p class="wp-block-paragraph">particular edge right there let me i want to be more interactive here how can i do this okay</p>



<p class="wp-block-paragraph">uh suppose i want to do</p>



<p class="wp-block-paragraph">612 node and so that&#8217;s going to be pointing to this edge right up here i want to see you know</p>



<p class="wp-block-paragraph">what&#8217;s going on with both of those nodes well if i was looking at the value-based edge list</p>



<p class="wp-block-paragraph">and i wanted to get a hold of let&#8217;s say the sixth node itself so i can like do something with that</p>



<p class="wp-block-paragraph">vertex like delete it or move it or just whatever i would have to then scan the entire vertex list</p>



<p class="wp-block-paragraph">i&#8217;d have to go you know this one this one this one this one this one until i eventually found</p>



<p class="wp-block-paragraph">the corresponding value.</p>



<p class="wp-block-paragraph">uh the corresponding value this wouldn&#8217;t really support duplicate values either</p>



<p class="wp-block-paragraph">uh it would be kind of hard to do that but uh i&#8217;ve i&#8217;ve slowed down the program it&#8217;s linear</p>



<p class="wp-block-paragraph">time based on the number of vertexes and if you&#8217;re already doing linear time based on the number of</p>



<p class="wp-block-paragraph">edges this is like it&#8217;s technically still a scalable data structure but it&#8217;s not super fast</p>



<p class="wp-block-paragraph">it could be faster on the other hand uh so like i just said uh sorry for repeating myself if we did</p>



<p class="wp-block-paragraph">the index</p>



<p class="wp-block-paragraph">the index based uh edge list it says two three here which is the 612 how can i find the sixth</p>



<p class="wp-block-paragraph">node well i just look at index two and instead of scanning oh gosh hang on</p>



<p class="wp-block-paragraph">i&#8217;m not as fast as i used to be okay dude there&#8217;s like did you see that uh</p>



<p class="wp-block-paragraph">a whole bunch of pink dots everywhere now what have i done okay</p>



<p class="wp-block-paragraph">So, uh…</p>



<p class="wp-block-paragraph">so uh i&#8217;m looking at the 612 edge i see that the indexes are two and three that means in constant</p>



<p class="wp-block-paragraph">time i can just jump directly to i guess i&#8217;ll put it in red in constant time index two right there</p>



<p class="wp-block-paragraph">and index three right there i do not have to scan the vertex list or the vector i guess if it was a</p>



<p class="wp-block-paragraph">vertex list like an actual linked list then i&#8217;d still have to scan because it&#8217;s linear time to do</p>



<p class="wp-block-paragraph">it but if it&#8217;s a vector</p>



<p class="wp-block-paragraph">But if it&#8217;s a vector or an array, I can just jump to an index in constant time, so it&#8217;s way faster.</p>



<p class="wp-block-paragraph">So what I&#8217;m trying to say is that this representation is what you want to do in the code when it comes to, I don&#8217;t know, representing diagrams and stuff.</p>



<p class="wp-block-paragraph">I don&#8217;t know. The one on the left is more human friendly.</p>



<p class="wp-block-paragraph">So this is the basic idea for how to represent an unweighted and also undirected graph in the machine using the edge list method of representation.</p>



<p class="wp-block-paragraph">i guess i&#8217;m going to cut the video i hope you learned a little bit of stuff and had</p>



<p class="wp-block-paragraph">a little bit of fun in the next video i think i&#8217;m going to do uh weighted uh undirected graphs</p>



<p class="wp-block-paragraph">and this i&#8217;m going to do four videos for this one representation type i&#8217;m going to do unweighted</p>



<p class="wp-block-paragraph">undirected and then weighted and undirected and then unweighted and directed i&#8217;m gonna</p>



<p class="wp-block-paragraph">do all four combinations all right see you in the next video thanks for watching</p>



<p class="wp-block-paragraph">hey everybody thanks for watching this video again from the bottom of my heart i really appreciate it</p>



<p class="wp-block-paragraph">i do hope you did learn something and have some fun if you could do me a please a small little</p>



<p class="wp-block-paragraph">favor could you please subscribe and follow this channel or these videos or whatever it is you do</p>



<p class="wp-block-paragraph">on the current social media website that you&#8217;re looking at right now it would really mean the</p>



<p class="wp-block-paragraph">world to me and it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do more</p>



<p class="wp-block-paragraph">videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general.</p>



<p class="wp-block-paragraph">just i&#8217;ll be able to keep making videos in general so please do do me a kindness and uh and subscribe</p>



<p class="wp-block-paragraph">you know sometimes i&#8217;m sleeping in the middle of the night and i just wake up because i know</p>



<p class="wp-block-paragraph">somebody subscribed or followed it just wakes me up and i get filled with joy that&#8217;s exactly what</p>



<p class="wp-block-paragraph">happens every single time so you could do it as a nice favor to me or you could you could troll me</p>



<p class="wp-block-paragraph">if you want to just wake me up in the middle of the night just subscribe and then i&#8217;ll i&#8217;ll just</p>



<p class="wp-block-paragraph">wake up i promise that&#8217;s what will happen also uh if you look at the middle of the screen right now</p>



<p class="wp-block-paragraph">you should see a QR code, which</p>



<p class="wp-block-paragraph">screen right now you should see a QR code which you can scan in order to go to the website which</p>



<p class="wp-block-paragraph">I think is also named somewhere at the bottom of this video and it&#8217;ll take you to my main website</p>



<p class="wp-block-paragraph">where you can just kind of like see all the videos I published and the services and tutorials and</p>



<p class="wp-block-paragraph">things that I offer and all that good stuff and if you have a suggestion for clarifications or</p>



<p class="wp-block-paragraph">errata or just future videos that you want to see please leave a comment or if you just want to say</p>



<p class="wp-block-paragraph">hey what&#8217;s up what&#8217;s going on you know just send</p>



<p class="wp-block-paragraph">what&#8217;s going on? You know, just send me a comment, whatever. I also wake up for those in the middle</p>



<p class="wp-block-paragraph">of the night. I get, I wake up in a cold sweat and I&#8217;m like, it would really, it really mean</p>



<p class="wp-block-paragraph">the world to me. I would really appreciate it. So again, thank you so much for watching this video</p>



<p class="wp-block-paragraph">and, um, enjoy the cool music as, as I fade into the darkness, which is coming for us all.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Thanks for watching!</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-represent-an-unweighted-undirected-graph-with-an-edge-list/">How to Represent an Unweighted Undirected Graph with an Edge List</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/how-to-represent-an-unweighted-undirected-graph-with-an-edge-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Graph Paths Explained: Node vs Edge Based, Simple Paths, Cycles and DAGs</title>
		<link>https://www.NeuralLantern.com/graph-paths-explained-node-vs-edge-based-simple-paths-cycles-and-dags/</link>
					<comments>https://www.NeuralLantern.com/graph-paths-explained-node-vs-edge-based-simple-paths-cycles-and-dags/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Wed, 05 Aug 2026 07:17:18 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[cyclic path]]></category>
		<category><![CDATA[DAG]]></category>
		<category><![CDATA[directed acyclic graph]]></category>
		<category><![CDATA[edge based path]]></category>
		<category><![CDATA[edge list]]></category>
		<category><![CDATA[graph algorithms basics]]></category>
		<category><![CDATA[graph cycles]]></category>
		<category><![CDATA[graph edges]]></category>
		<category><![CDATA[graph paths]]></category>
		<category><![CDATA[graph theory]]></category>
		<category><![CDATA[node based path]]></category>
		<category><![CDATA[paths in graphs]]></category>
		<category><![CDATA[simple path graph]]></category>
		<category><![CDATA[weighted graphs]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=420</guid>

					<description><![CDATA[<p>Paths in a graph show how to travel from a start node to a destination. Node-based paths list the nodes visited but cannot distinguish parallel edges with different weights. Edge-based paths use tuples of start node, destination node and weight so every route is exact. Simple paths repeat no edges or vertices. Cyclic paths start and end on the same node and prove the graph is cyclic. A DAG is a directed acyclic graph with no cycles. These ideas prepare for graph algorithms.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-paths-explained-node-vs-edge-based-simple-paths-cycles-and-dags/">Graph Paths Explained: Node vs Edge Based, Simple Paths, Cycles and DAGs</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Graph Paths Explained: Node vs Edge Based, Simple Paths, Cycles and DAGs" width="1380" height="776" src="https://www.youtube.com/embed/B1cK5ajqKx0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Hey there, let&#8217;s talk about paths inside of a graph. We draw a directed weighted graph and compare node-based paths to edge-based paths. Node lists alone cannot tell which edge you took when parallel edges have different costs. Edge-based paths use tuples of start, destination and weight so every route is clear.</p>



<p class="wp-block-paragraph">We also cover simple paths with no repeated edges or vertices, cyclic paths that start and end on the same node, and how a cycle proves the graph is cyclic. Then we explain DAGs, directed acyclic graphs, with examples that stay acyclic and ones that gain cycles.</p>



<p class="wp-block-paragraph">This sets up algorithms for later videos. Leave a comment with topics you want next. Thanks for watching and please subscribe.</p>



<p class="wp-block-paragraph">00:00 Introduction to Graph Paths<br>00:28 Drawing a Sample Graph<br>02:25 What is a Path<br>02:42 Node-Based Paths<br>03:27 Adding Weights and Parallel Edges<br>04:34 Example Paths with Different Costs<br>07:19 Edge-Based Paths<br>07:35 Representing Paths with Tuples<br>11:35 Order Matters in Directed Graphs<br>12:52 Simple Paths<br>15:34 Cyclic Paths<br>18:22 Directed Acyclic Graphs DAGs<br>19:08 Building a DAG Example<br>21:41 Adding a Cycle to Break the DAG<br>23:15 Conclusion and Future Videos</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p class="wp-block-paragraph">Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hey there, let&#8217;s talk about paths inside of a graph.</p>



<p class="wp-block-paragraph">Okay, so first thing that I&#8217;ll say is you probably should have watched my other videos already so that you understand at least the basics of graphs or maybe you already know and you just came here for a little extra.</p>



<p class="wp-block-paragraph">So let&#8217;s just draw a sample graph here.</p>



<p class="wp-block-paragraph">I&#8217;m going to do like random nodes.</p>



<p class="wp-block-paragraph">Let&#8217;s see what am I supposed to do.</p>



<p class="wp-block-paragraph">I&#8217;m supposed to like full screen that.</p>



<p class="wp-block-paragraph">I&#8217;m going to draw some random nodes with some random values inside of them.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to do like a three here.</p>



<p class="wp-block-paragraph">Maybe like a three like that.</p>



<p class="wp-block-paragraph">And then I&#8217;m going to duplicate this a few times.</p>



<p class="wp-block-paragraph">So I&#8217;m going to go.</p>



<p class="wp-block-paragraph">This is a valid graph.</p>



<p class="wp-block-paragraph">It&#8217;s just not a connected graph as we talked about in my last video.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to do this.</p>



<p class="wp-block-paragraph">I guess that&#8217;s okay.</p>



<p class="wp-block-paragraph">I&#8217;m going to change all these numbers.</p>



<p class="wp-block-paragraph">Even though your graph should be able to support duplicate values in the nodes,</p>



<p class="wp-block-paragraph">it&#8217;s going to be really hard to explain.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to change all this stuff.</p>



<p class="wp-block-paragraph">9 here and then like 22.</p>



<p class="wp-block-paragraph">I think that&#8217;s probably good.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do this.</p>



<p class="wp-block-paragraph">And this.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So still a valid graph, but there&#8217;s no chance that we could have a path anywhere in this</p>



<p class="wp-block-paragraph">entire graph.</p>



<p class="wp-block-paragraph">anywhere in this entire graph so that sucks we could by the way do a path</p>



<p class="wp-block-paragraph">with a undirected graph but I kind of feel like I want to do direction on all</p>



<p class="wp-block-paragraph">the edges so let&#8217;s see let&#8217;s do direction and also weight I&#8217;m gonna like draw an</p>



<p class="wp-block-paragraph">arrow here and arrow here there I&#8217;m gonna draw edges first in a way that it</p>



<p class="wp-block-paragraph">like I could find a path almost anywhere I want so I&#8217;m just going to like draw a bunch of edges</p>



<p class="wp-block-paragraph">maybe like another edge over here nope that&#8217;s wrong how about this maybe another edge going up</p>



<p class="wp-block-paragraph">here and an edge going up here and an edge going down there I&#8217;m just going to draw a whole bunch</p>



<p class="wp-block-paragraph">of edges in the hopes that we&#8217;ll have a decent graph with lots of path possibilities okay I guess</p>



<p class="wp-block-paragraph">Oh, no, no, this is not a complete graph.</p>



<p class="wp-block-paragraph">I&#8217;ve just drawn a graph where you can kind of get everywhere.</p>



<p class="wp-block-paragraph">Okay, so, well, I mean, what is a path?</p>



<p class="wp-block-paragraph">It&#8217;s just sort of like, you know, some sort of a representation of how do you get from</p>



<p class="wp-block-paragraph">one start node to some destination node, like a map.</p>



<p class="wp-block-paragraph">So the first thing that we could do is we could say, let&#8217;s make a path based on nodes.</p>



<p class="wp-block-paragraph">I&#8217;m going to say node-based paths.</p>



<p class="wp-block-paragraph">Actually, let me get rid of this and put it on the next slide.</p>



<p class="wp-block-paragraph">We&#8217;ll do this, duplicate it, that way I have the original.</p>



<p class="wp-block-paragraph">Let&#8217;s pretend that our path is going to be just a list of nodes that we travel through.</p>



<p class="wp-block-paragraph">So I&#8217;m going to say node-based and we&#8217;ll have one path, we&#8217;ll say path1 and then path2,</p>



<p class="wp-block-paragraph">maybe we&#8217;ll do like a second path.</p>



<p class="wp-block-paragraph">well at first we might think this is totally fine but uh later on it&#8217;ll get confusing in terms of</p>



<p class="wp-block-paragraph">which edge did we actually take so let me show you let me show you what i mean i&#8217;m first going</p>



<p class="wp-block-paragraph">to add weights to all the edges so i&#8217;m just going to do like you know four and a three over here</p>



<p class="wp-block-paragraph">and then like a one and a two little one and then like a six and then like a four i&#8217;m just adding</p>



<p class="wp-block-paragraph">random weights or random costs to all of the edges and um then eventually let&#8217;s see when i</p>



<p class="wp-block-paragraph">let&#8217;s see when I finish doing all of that eventually we can probably realize that we</p>



<p class="wp-block-paragraph">could add more than one edge going from the same start to the same destination node but give it a</p>



<p class="wp-block-paragraph">different weight so that we have a little bit more of a choice so suppose for the sake of argument</p>



<p class="wp-block-paragraph">that we have this six and the four here the six can go to the four at a cost of four but maybe the</p>



<p class="wp-block-paragraph">a cost of one. I don&#8217;t know why it&#8217;s there. I don&#8217;t know why the four is there. Also,</p>



<p class="wp-block-paragraph">we&#8217;ll just say this is our graph. So you can have edges like this that go to the same start</p>



<p class="wp-block-paragraph">and destination nodes, but have different weights. So a path that is based on nodes</p>



<p class="wp-block-paragraph">doesn&#8217;t really have enough information to tell us which edge we took. Let me show you what I mean.</p>



<p class="wp-block-paragraph">So suppose we want to get from node, I don&#8217;t know, node three, I&#8217;ll put an S here for start.</p>



<p class="wp-block-paragraph">for start. And then I guess I&#8217;ll put a D for destination or donut. I&#8217;ll put a D there on</p>



<p class="wp-block-paragraph">node number 22. So we&#8217;ll say we&#8217;re going to go from node three to node 22. So start and destination</p>



<p class="wp-block-paragraph">a path based, sorry, a node based path, path one, we could say maybe let&#8217;s go from the three</p>



<p class="wp-block-paragraph">to the six to the four to the 12 to the nine to the 22 and that tells you all the notes that</p>



<p class="wp-block-paragraph">you would hop on another path could be let&#8217;s see that first path when we went from three one six</p>



<p class="wp-block-paragraph">four twelve nine uh 22 when we go from the six to the four we could have a second path here</p>



<p class="wp-block-paragraph">that goes from three to one to six to four but takes a different edge this is kind of what i&#8217;m</p>



<p class="wp-block-paragraph">this is kind of what i&#8217;m trying to show you notice that we have two different paths i&#8217;m going to do</p>



<p class="wp-block-paragraph">one in uh maybe red so it&#8217;s going to be three one six four so from three to one and then six</p>



<p class="wp-block-paragraph">and then we&#8217;ll travel along that four edge once we get to the four we&#8217;ll go 12 and then once we</p>



<p class="wp-block-paragraph">Then the other path, path number two, let&#8217;s say that we chose the other edge.</p>



<p class="wp-block-paragraph">We chose the six to the four edge that only cost us one.</p>



<p class="wp-block-paragraph">So it would kind of look the same for the most part, except when we finally get to that</p>



<p class="wp-block-paragraph">other node, we&#8217;re actually going to be going this way, right?</p>



<p class="wp-block-paragraph">And then we&#8217;re going to go up and then to the right and then down.</p>



<p class="wp-block-paragraph">So if you look at this carefully for a little while, maybe pause the video.</p>



<p class="wp-block-paragraph">These are actually two totally different paths with two totally different costs.</p>



<p class="wp-block-paragraph">different costs. So, um, you know, the cost of the orange, let me write it in orange.</p>



<p class="wp-block-paragraph">It&#8217;s going to be five plus one. So six, and then a seven there, and then a eight, nine there. And</p>



<p class="wp-block-paragraph">then, uh, then I guess like a 15 there and then a 16 there. So the cost of the orange pass is going</p>



<p class="wp-block-paragraph">to be 16. If we switch to the red path, the only difference is the choice of edge we took between</p>



<p class="wp-block-paragraph">we took between the six and the four node.</p>



<p class="wp-block-paragraph">So we would increase our cost by three.</p>



<p class="wp-block-paragraph">So the red path would be a cost of 19.</p>



<p class="wp-block-paragraph">But how can you tell the difference in a path</p>



<p class="wp-block-paragraph">that is based on a node?</p>



<p class="wp-block-paragraph">It doesn&#8217;t have enough information, right?</p>



<p class="wp-block-paragraph">So what we&#8217;re gonna do instead</p>



<p class="wp-block-paragraph">is we&#8217;re gonna use edge-based paths.</p>



<p class="wp-block-paragraph">Edge-based paths.</p>



<p class="wp-block-paragraph">In some places, you know, you can use node-based paths.</p>



<p class="wp-block-paragraph">That&#8217;s totally fine.</p>



<p class="wp-block-paragraph">fine but for me I&#8217;m going to say let&#8217;s do edge based paths edge based paths and now we just have</p>



<p class="wp-block-paragraph">to figure out how to add that extra information into the path so going from the three to the one</p>



<p class="wp-block-paragraph">we&#8217;re actually traveling along an edge right we&#8217;re traveling along that five edge so let&#8217;s just stick</p>



<p class="wp-block-paragraph">a tuple in there a tuple meaning just a little collection of values for those of you in c++ if</p>



<p class="wp-block-paragraph">items we&#8217;re going to use three item tuples tuples not always limited to three items it could be two</p>



<p class="wp-block-paragraph">three four even probably one um or much more so i&#8217;m going to say let&#8217;s use a tuple that has three</p>



<p class="wp-block-paragraph">items per item or tuple and we&#8217;ll just say that we specify the start node and then the destination</p>



<p class="wp-block-paragraph">node so we start at three we go to one and then the weight of the edge that we choose to travel</p>



<p class="wp-block-paragraph">but we&#8217;re putting enough information into our hop</p>



<p class="wp-block-paragraph">that this can be considered an edge-based path.</p>



<p class="wp-block-paragraph">So when we go to the one node,</p>



<p class="wp-block-paragraph">we ended on the one node, sorry, we&#8217;ve gone to the one node.</p>



<p class="wp-block-paragraph">We just ended there.</p>



<p class="wp-block-paragraph">So we could start on the one node for the next tuple</p>



<p class="wp-block-paragraph">because then we&#8217;re going to go to the,</p>



<p class="wp-block-paragraph">what are we doing first, red?</p>



<p class="wp-block-paragraph">I think we&#8217;re doing red first, yeah.</p>



<p class="wp-block-paragraph">We go from the one node to the six nodes.</p>



<p class="wp-block-paragraph">So I&#8217;m going to go comma six.</p>



<p class="wp-block-paragraph">and then we choose which edge to travel along that&#8217;s just the one edge and so 161 means start</p>



<p class="wp-block-paragraph">at the one node and at the six node and take the one weighted edge then do the same thing</p>



<p class="wp-block-paragraph">again for the next tuple so we&#8217;re at the six now where are we going to go we&#8217;re going to go to the</p>



<p class="wp-block-paragraph">four and then we choose the edge that costs four and then for the next tuple we&#8217;re on the four</p>



<p class="wp-block-paragraph">I&#8217;m going to say 12 is the destination and which edge did we choose the two even though there&#8217;s</p>



<p class="wp-block-paragraph">only one choice at least we have enough information for all edges in our entire path so then again</p>



<p class="wp-block-paragraph">we&#8217;re at the 12 we&#8217;re going to go to the 9 so I&#8217;m going to put a common 9 there and then we choose</p>



<p class="wp-block-paragraph">to take the edge that uh what was that cost six I can&#8217;t read anymore um let me actually just look</p>



<p class="wp-block-paragraph">real fast six I guess I overrode it I&#8217;m just going to assume that it&#8217;s a six um I&#8217;ve got</p>



<p class="wp-block-paragraph">I guess I could erase it real fast</p>



<p class="wp-block-paragraph">or move it or something</p>



<p class="wp-block-paragraph">okay let&#8217;s see what is that</p>



<p class="wp-block-paragraph">yeah it&#8217;s a 6 okay</p>



<p class="wp-block-paragraph">so we&#8217;re on the 12 we&#8217;re going to go to the 9</p>



<p class="wp-block-paragraph">and we choose to take the edge that costs 6</p>



<p class="wp-block-paragraph">then we&#8217;re on the 9</p>



<p class="wp-block-paragraph">and we choose to go to the 22</p>



<p class="wp-block-paragraph">using the edge that costs 2</p>



<p class="wp-block-paragraph">and then this last thing doesn&#8217;t need to be done</p>



<p class="wp-block-paragraph">because we have the entirety of the path</p>



<p class="wp-block-paragraph">in our edge based list</p>



<p class="wp-block-paragraph">So I&#8217;m actually just going to copy paste this entire path and stick it into the second path</p>



<p class="wp-block-paragraph">because remember the only difference between the first path and the second path that we</p>



<p class="wp-block-paragraph">chose is when we were going from 6 to 4 we chose the 1 edge instead of the 4 edge.</p>



<p class="wp-block-paragraph">So now look at this, I can just change that 4 to a 1 and now we definitely have two different</p>



<p class="wp-block-paragraph">paths and because we&#8217;re using edges to describe our path we can tell the difference.</p>



<p class="wp-block-paragraph">You know in a computer program we would know exactly which edge to travel along or even</p>



<p class="wp-block-paragraph">which edge to travel along or even just a user moving their finger along a graph or whatever.</p>



<p class="wp-block-paragraph">So in my opinion, edge-based paths are a little bit better.</p>



<p class="wp-block-paragraph">They&#8217;re also better because if you practice writing down edge lists like this,</p>



<p class="wp-block-paragraph">then you get a lot closer to a representation of a graph in your machine called an edge list.</p>



<p class="wp-block-paragraph">So in an edge list, oops, I put ed light.</p>



<p class="wp-block-paragraph">I don&#8217;t know why I did that.</p>



<p class="wp-block-paragraph">And now the computer&#8217;s not responding.</p>



<p class="wp-block-paragraph">So my mistake is immortalized.</p>



<p class="wp-block-paragraph">my mistake is immortalized. Edge list representation of a graph is basically a graph is equal to</p>



<p class="wp-block-paragraph">a tuple where one item in the tuple is a list of vertices and another item in the tuple</p>



<p class="wp-block-paragraph">is a list of edges. So if you learn how to do edge-based paths, then you&#8217;re already a step</p>



<p class="wp-block-paragraph">closer to being able to represent a graph inside of your computer program in the machine.</p>



<p class="wp-block-paragraph">So another thing that I want to point out is that since this graph has direction,</p>



<p class="wp-block-paragraph">the order of the start node and the destination node absolutely matters for example if we have</p>



<p class="wp-block-paragraph">this three comma one here indicating we start at three and we end at one well that means there must</p>



<p class="wp-block-paragraph">be an edge that points from three to one otherwise this is an invalid path if for some reason</p>



<p class="wp-block-paragraph">if for some reason let me get rid of this here there&#8217;s too much stuff on the screen</p>



<p class="wp-block-paragraph">three this is invalid because it&#8217;s saying that we have to start at the one node and end at the three</p>



<p class="wp-block-paragraph">node but the one node has no has no edge going to the three node so this is totally invalid</p>



<p class="wp-block-paragraph">does that make sense i hope it makes sense to you if this was an undirected graph where every single</p>



<p class="wp-block-paragraph">edge did not have direction then the order actually wouldn&#8217;t even matter you would just</p>



<p class="wp-block-paragraph">to see if an edge existed.</p>



<p class="wp-block-paragraph">So let&#8217;s see, we talked about different paths.</p>



<p class="wp-block-paragraph">You know, typically you would want to choose</p>



<p class="wp-block-paragraph">the lowest cost path,</p>



<p class="wp-block-paragraph">but there are algorithms that we can use</p>



<p class="wp-block-paragraph">in future videos to compute paths.</p>



<p class="wp-block-paragraph">Let&#8217;s see, something called a simple path</p>



<p class="wp-block-paragraph">is where every single edge in the path is distinct.</p>



<p class="wp-block-paragraph">So for example, I don&#8217;t know,</p>



<p class="wp-block-paragraph">let&#8217;s say we had like a really gross path here.</p>



<p class="wp-block-paragraph">Let me get rid of, let me get rid of some of this.</p>



<p class="wp-block-paragraph">Let me get rid of some of this.</p>



<p class="wp-block-paragraph">Get rid of the oranges maybe.</p>



<p class="wp-block-paragraph">So that this is a little slightly easier to read.</p>



<p class="wp-block-paragraph">Let&#8217;s see.</p>



<p class="wp-block-paragraph">Did we choose?</p>



<p class="wp-block-paragraph">Oh, I have to fix this.</p>



<p class="wp-block-paragraph">Let&#8217;s fix the three and then the one.</p>



<p class="wp-block-paragraph">And then we chose the four.</p>



<p class="wp-block-paragraph">So this is the red path indeed.</p>



<p class="wp-block-paragraph">So a simple path is, nope, I accidentally erased like an extra edge or something.</p>



<p class="wp-block-paragraph">So I got to do one from the four to the 12.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">to the 12 okay let me just do that real fast from the 4 to the 12. at a cost of 2. okay so a simple</p>



<p class="wp-block-paragraph">path is something where you don&#8217;t repeat edges so i can also write down simple path here simple path</p>



<p class="wp-block-paragraph">if this was not a simple path then we would just basically have to repeat an edge somewhere</p>



<p class="wp-block-paragraph">so um if any of the edges or vertices were repeated this would not be a simple path so let me just i</p>



<p class="wp-block-paragraph">would not be a simple path so let me just I don&#8217;t know let me just update this real fast let&#8217;s say</p>



<p class="wp-block-paragraph">we do oh what should we do let&#8217;s do I don&#8217;t know when we go from three to one to six to four</p>



<p class="wp-block-paragraph">let&#8217;s go back from four to six and then we&#8217;ll take the other edge back to four and then we&#8217;ll</p>



<p class="wp-block-paragraph">go up to 12 so this will be like um not a simple path if we say gosh I should have written this</p>



<p class="wp-block-paragraph">this down before i drew it three to one and then one to six and then six to four and then four back</p>



<p class="wp-block-paragraph">to six okay so i&#8217;m going to add another tuple so starting at four going back to six and taking</p>



<p class="wp-block-paragraph">that three edge i think is what we&#8217;re looking at and then another tuple to get back when we go from</p>



<p class="wp-block-paragraph">six to four and then take the um one cost edge and then once we&#8217;re at four then we can go four</p>



<p class="wp-block-paragraph">cost of two and then 12 to nine at a cost of six and then nine to 22 at a cost of two okay so</p>



<p class="wp-block-paragraph">i mean i&#8217;m just saying you can make a path where you just repeat a whole bunch of the edges and</p>



<p class="wp-block-paragraph">nodes and you&#8217;re just like going in a circle forever like whatever you really want it&#8217;s not</p>



<p class="wp-block-paragraph">necessarily going to be an efficient path or something that an algorithm should produce</p>



<p class="wp-block-paragraph">but you can have a path like that maybe your character is just going crazy in the game and</p>



<p class="wp-block-paragraph">because we repeat stuff on the previous slide.</p>



<p class="wp-block-paragraph">Since we did not repeat anything, this is a simple path.</p>



<p class="wp-block-paragraph">Okay, let&#8217;s see.</p>



<p class="wp-block-paragraph">Something else that I wanna talk about is a cyclic path.</p>



<p class="wp-block-paragraph">A cyclic path is basically a path</p>



<p class="wp-block-paragraph">where you start and end on the same node.</p>



<p class="wp-block-paragraph">Being able to find a cyclic path in a graph</p>



<p class="wp-block-paragraph">is a way that you can prove that the graph is itself cyclic.</p>



<p class="wp-block-paragraph">is itself cyclic. Let me try to get rid of this here. Yeah, there we go. Okay, so just</p>



<p class="wp-block-paragraph">pretend for the sake of argument that I&#8217;m just kind of looking around and I&#8217;m trying to find,</p>



<p class="wp-block-paragraph">you know, some path that proves I can start at the same node and end on that node without</p>



<p class="wp-block-paragraph">repeating edges. So let&#8217;s see. Right, so I&#8217;m going to do take the three and go to the six.</p>



<p class="wp-block-paragraph">to the six and then so i want to try if i start on the three then i want to try to find a way to get</p>



<p class="wp-block-paragraph">back to the three again so i go from three to six and then i can go from six to four</p>



<p class="wp-block-paragraph">and then if i go from four to six over here i&#8217;m not repeating that edge going from six to four i&#8217;m</p>



<p class="wp-block-paragraph">using a new edge from four to six and then i can go from six to three again not actually repeating</p>



<p class="wp-block-paragraph">means I have found a cycle in the graph. Let me just describe this path real fast in terms of</p>



<p class="wp-block-paragraph">edges. So we started on three. Oops. We started on three and then we went to six and it cost us three.</p>



<p class="wp-block-paragraph">And then once we were on six, we went to four. So I&#8217;m going to go from six to four. And we chose</p>



<p class="wp-block-paragraph">the edge that cost us four. And then once we were on the four, we just went backwards to the six.</p>



<p class="wp-block-paragraph">four going to six and we took the edge that cost three once we were on six we took the six to three</p>



<p class="wp-block-paragraph">edge so six to three whoops six to three edge and that cost us three yeah did I do that right</p>



<p class="wp-block-paragraph">when we go from the three to the six in the beginning I wrote down a three but I should</p>



<p class="wp-block-paragraph">have written down a two hopefully you cringed on my behalf right because I was I think that red</p>



<p class="wp-block-paragraph">on the left side so my brain was looking at the three but we were really taking the arrow that</p>



<p class="wp-block-paragraph">points down from the three to the six so there&#8217;s a two there let me just double check one more time</p>



<p class="wp-block-paragraph">six to four at cost of four four to six at cost of three six two three at cost of three</p>



<p class="wp-block-paragraph">so we have started and ended uh on the same node and therefore we have found a cycle in this graph</p>



<p class="wp-block-paragraph">which means this graph is cyclic what is cyclic just means it&#8217;s a graph that has a cycle</p>



<p class="wp-block-paragraph">It&#8217;s a graph that has a cycle anywhere inside of it.</p>



<p class="wp-block-paragraph">So this is a cyclic graph.</p>



<p class="wp-block-paragraph">Make sense?</p>



<p class="wp-block-paragraph">Okay, why is this important?</p>



<p class="wp-block-paragraph">Well, there&#8217;s kind of like a special type of graph called a DAG,</p>



<p class="wp-block-paragraph">which means a directed…</p>



<p class="wp-block-paragraph">Here, let me write this down real fast.</p>



<p class="wp-block-paragraph">On the next slide, so that we don&#8217;t get confused.</p>



<p class="wp-block-paragraph">On the next slide, I&#8217;m going to say we have a DAG</p>



<p class="wp-block-paragraph">is basically a directed…</p>



<p class="wp-block-paragraph">directed, acyclic graph. What does A mean when it&#8217;s in front of something? It just means it&#8217;s</p>



<p class="wp-block-paragraph">not that thing. So acyclic means not cyclic and then graph. So in some algorithms you are required</p>



<p class="wp-block-paragraph">to, you know, like have a DAG before you can even use the algorithm or if you&#8217;re being tested</p>



<p class="wp-block-paragraph">somewhere. So let&#8217;s just start by, you know, drawing like a little bit of a graph and we&#8217;ll</p>



<p class="wp-block-paragraph">have a graph that qualifies. So I have a little graph here. If it was empty,</p>



<p class="wp-block-paragraph">I don&#8217;t know if you could call it a DAG or not. I think I would because it&#8217;s empty. It could be</p>



<p class="wp-block-paragraph">directed. So we have like a graph here. I would call this a DAG because it&#8217;s a graph. We don&#8217;t</p>



<p class="wp-block-paragraph">have any edges, but like I could assume that this would be a directed graph. But just to make this</p>



<p class="wp-block-paragraph">a better example, let&#8217;s just say we have like two nodes here. And you could also probably assume</p>



<p class="wp-block-paragraph">DAG because you could assume that there are no edges in this graph but if we did add an edge</p>



<p class="wp-block-paragraph">a second from now then it would be directed not the best example but so let&#8217;s just add an edge here</p>



<p class="wp-block-paragraph">oh actually let&#8217;s add an edge that&#8217;s undirected real fast from from two to six and then maybe</p>



<p class="wp-block-paragraph">I&#8217;ll just kind of duplicate some of these we&#8217;ll do a couple more so I can just make this more</p>



<p class="wp-block-paragraph">so ask yourself is this a DAG directed acyclic well there are no cycles that I can see in the</p>



<p class="wp-block-paragraph">graph there&#8217;s no paths that you can find to kind of like end where you started but this is a it is</p>



<p class="wp-block-paragraph">a graph and I don&#8217;t see any cycles but it&#8217;s not directed because these edges don&#8217;t have direction</p>



<p class="wp-block-paragraph">so that means right away we have to upgrade every single edge to have direction so I guess I was</p>



<p class="wp-block-paragraph">going to draw a bunch more edges and now I&#8217;m just going to only draw this one edge</p>



<p class="wp-block-paragraph">So this is definitely a DAG if we just sort of do it like this, maybe another edge like this,</p>



<p class="wp-block-paragraph">because I don&#8217;t know about you, but I cannot find any path that allows me to start and end</p>



<p class="wp-block-paragraph">on the same node. Let&#8217;s just double check it. We&#8217;ll do the two. Can we find our way back to</p>



<p class="wp-block-paragraph">the two? No, because there are no incoming edges to the two. All right, that&#8217;s good. Let me just</p>



<p class="wp-block-paragraph">do a check here. What about the six? If we go out to the six, from the six to the four to the</p>



<p class="wp-block-paragraph">6 from the 6 to the 4 to the 11 it would have been dangerous if we could get to the 2 but we</p>



<p class="wp-block-paragraph">can&#8217;t even get to the 2 so that&#8217;s fine that means the 6 is okay we cannot find our way back there</p>



<p class="wp-block-paragraph">the 4 we can go to the 11 but we can&#8217;t go any further we&#8217;re at a dead end we can&#8217;t even go to</p>



<p class="wp-block-paragraph">the 6 that means the 4 can&#8217;t find its way back to itself where you can&#8217;t find a path that goes back</p>



<p class="wp-block-paragraph">the 11 has only incoming edges so that&#8217;s automatically you know a dead end so all of</p>



<p class="wp-block-paragraph">nodes qualify as we could not start and also end at that node with a single path so that&#8217;s good</p>



<p class="wp-block-paragraph">that means this is a DAG a directed acyclic graph if you want to make this into not a DAG just figure</p>



<p class="wp-block-paragraph">out how to add a path so that you end up with a cycle so what was the first thing we did the 2</p>



<p class="wp-block-paragraph">goes to the 6 goes to the 4 goes to 11 then it&#8217;s a dead end we could either add an edge from 11 to 2</p>



<p class="wp-block-paragraph">to make a cycle but that&#8217;s a little bit too easy right because if you see any pair of nodes</p>



<p class="wp-block-paragraph">right because if you see any pair of nodes with arrows kind of pointing back and forth between the</p>



<p class="wp-block-paragraph">two nodes then right away that alone is a cycle so I&#8217;m just going to maybe do an arrow or an edge</p>



<p class="wp-block-paragraph">pointing from four to two then it doesn&#8217;t look so much like a cycle although it&#8217;s not too hard</p>



<p class="wp-block-paragraph">to realize that there is a cycle in this graph in this graph so this is not a DAG let me show you</p>



<p class="wp-block-paragraph">and then from four to two.</p>



<p class="wp-block-paragraph">And therefore we would have a cycle.</p>



<p class="wp-block-paragraph">So this whole graph is not considered acyclic.</p>



<p class="wp-block-paragraph">This graph has a cycle.</p>



<p class="wp-block-paragraph">And if we want to do an edge-based path,</p>



<p class="wp-block-paragraph">we don&#8217;t have weights on this graph right now.</p>



<p class="wp-block-paragraph">So we could describe the path as such.</p>



<p class="wp-block-paragraph">We could say, start at two, go to six.</p>



<p class="wp-block-paragraph">And if your edge list is of a graph</p>



<p class="wp-block-paragraph">that doesn&#8217;t even have weight at all,</p>



<p class="wp-block-paragraph">then you don&#8217;t really need that third item in the tuple.</p>



<p class="wp-block-paragraph">item in the tuple you can just do a start node and a destination node this does kind of preclude</p>



<p class="wp-block-paragraph">you from having parallel edges you know two different edges that point from the same start</p>



<p class="wp-block-paragraph">node to the same end node so as i go from two to six and then from six to uh four and then from</p>



<p class="wp-block-paragraph">four to two and then we have a cycle and that&#8217;s it okay i think this is all i really wanted to</p>



<p class="wp-block-paragraph">talk about for this particular video in future videos we&#8217;re going to do algorithms and then</p>



<p class="wp-block-paragraph">some others up already that have graph properties and connectedness and definitions and things like</p>



<p class="wp-block-paragraph">that. So leave a comment asking about some algorithm or some property of a graph that</p>



<p class="wp-block-paragraph">you might be interested in. Otherwise, thank you so much for watching this video. I hope you learned</p>



<p class="wp-block-paragraph">a little bit of stuff. And I hope you had a little bit of fun. I&#8217;ll see you in the next video.</p>



<p class="wp-block-paragraph">Yeah, I&#8217;m gonna go eat some cookies. No, I shouldn&#8217;t do that. But I&#8217;m still going to.</p>



<p class="wp-block-paragraph">Hey everybody, thanks for watching this video again from the bottom of my heart.</p>



<p class="wp-block-paragraph">I really appreciate it.</p>



<p class="wp-block-paragraph">I do hope you did learn something and have some fun.</p>



<p class="wp-block-paragraph">If you could do me a please, a small little favor, could you please subscribe and follow</p>



<p class="wp-block-paragraph">this channel or these videos or whatever it is you do on the current social media website</p>



<p class="wp-block-paragraph">that you&#8217;re looking at right now.</p>



<p class="wp-block-paragraph">It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p class="wp-block-paragraph">So we&#8217;ll be able to do more videos, longer videos, better videos, or just I&#8217;ll be able</p>



<p class="wp-block-paragraph">better videos or just I&#8217;ll be able to keep making videos in general so please</p>



<p class="wp-block-paragraph">do do me a kindness and and subscribe you know sometimes I&#8217;m sleeping in the</p>



<p class="wp-block-paragraph">middle of the night and I just wake up because I know somebody subscribed or</p>



<p class="wp-block-paragraph">followed it just wakes me up and I get filled with joy that&#8217;s exactly what</p>



<p class="wp-block-paragraph">happens every single time so you could do it as a nice favor to me or you could</p>



<p class="wp-block-paragraph">you control me if you want to just wake me up in the middle of the night just</p>



<p class="wp-block-paragraph">subscribe and then I&#8217;ll just wake up I promise that&#8217;s what will happen also if</p>



<p class="wp-block-paragraph">if you look at the middle of the screen right now you should see a qr code which you can scan</p>



<p class="wp-block-paragraph">in order to go to the website which i think is also named somewhere at the bottom of this video</p>



<p class="wp-block-paragraph">and it&#8217;ll take you to my main website where you can just kind of like see all the videos i</p>



<p class="wp-block-paragraph">published and the services and tutorials and things that i offer and all that good stuff and</p>



<p class="wp-block-paragraph">if you have a suggestion for uh clarifications or errata or just future videos that you want to see</p>



<p class="wp-block-paragraph">Or if you just want to say, hey, what&#8217;s up?</p>



<p class="wp-block-paragraph">What&#8217;s going on?</p>



<p class="wp-block-paragraph">You know, just send me a comment, whatever.</p>



<p class="wp-block-paragraph">I also wake up for those in the middle of the night.</p>



<p class="wp-block-paragraph">I get, I wake up in a cold sweat and I&#8217;m like,</p>



<p class="wp-block-paragraph">it would really, it really mean the world to me.</p>



<p class="wp-block-paragraph">I would really appreciate it.</p>



<p class="wp-block-paragraph">So again, thank you so much for watching this video</p>



<p class="wp-block-paragraph">and enjoy the cool music as I fade into the darkness,</p>



<p class="wp-block-paragraph">which is coming for us all.</p>



<p class="wp-block-paragraph">so</p>



<p class="wp-block-paragraph">Thank you.</p>



<p class="wp-block-paragraph">I&#8217;m going to go ahead and get started.</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-paths-explained-node-vs-edge-based-simple-paths-cycles-and-dags/">Graph Paths Explained: Node vs Edge Based, Simple Paths, Cycles and DAGs</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/graph-paths-explained-node-vs-edge-based-simple-paths-cycles-and-dags/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected</title>
		<link>https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/</link>
					<comments>https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sat, 25 Jul 2026 23:04:51 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[connected graph]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[directed graph]]></category>
		<category><![CDATA[graph algorithms]]></category>
		<category><![CDATA[graph connectedness]]></category>
		<category><![CDATA[graph paths]]></category>
		<category><![CDATA[graph theory]]></category>
		<category><![CDATA[nodes and edges]]></category>
		<category><![CDATA[strongly connected graph]]></category>
		<category><![CDATA[subgraphs]]></category>
		<category><![CDATA[undirected graph]]></category>
		<category><![CDATA[weakly connected graph]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=417</guid>

					<description><![CDATA[<p>This video explains graph connectedness for both undirected and directed graphs. For undirected graphs a connected graph means every node can reach every other node through a path. Disconnected graphs have nodes that cannot reach others and may contain separate subgraphs. For directed graphs the terms change to strongly connected where every node reaches every other node following edge directions and weakly connected where the graph is connected if directions are ignored. Step by step examples show how adding edges turns a graph from not connected to weakly connected and finally to strongly connected.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/">Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected" width="1380" height="776" src="https://www.youtube.com/embed/u1D6huK1DCA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Hello there. Lets talk about graphs and whether they are connected or not or maybe whether they are strongly connected versus weakly connected. We look at undirected graphs first and show what makes a graph connected meaning every node can reach every other node by a path. We add edges and check the connections step by step while also noting subgraphs. Then we switch to directed graphs and explain strongly connected versus weakly connected. Strongly connected follows the edge directions for every path. Weakly connected ignores the directions and checks if the graph would still be connected. Examples show how adding edges changes the status of the graph.</p>



<p class="wp-block-paragraph">00:00 Introduction to Graph Connectedness<br>00:01 Drawing Nodes and a Disconnected Graph<br>01:56 Defining a Connected Graph<br>03:21 Introducing Subgraphs<br>04:48 Adding Edges to Create a Connected Graph<br>06:32 Adding Directions to Create a Directed Graph<br>08:03 Strongly Connected Versus Weakly Connected<br>08:34 Removing an Edge to Show Disconnection<br>09:29 Checking and Achieving Weak Connectivity<br>11:18 Adding Edges to Create a Strongly Connected Graph<br>13:20 Confirming the Strongly Connected Graph<br>13:32 Conclusion<br>14:17 Outro and Subscribe Request</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p class="wp-block-paragraph">Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hello there! Let&#8217;s talk about graphs and whether they&#8217;re connected or not or maybe whether they&#8217;re</p>



<p class="wp-block-paragraph">strongly connected versus weakly connected versus not connected. You never know.</p>



<p class="wp-block-paragraph">Okay, so hopefully you&#8217;ve seen my previous videos by now where we just talked about the basics of</p>



<p class="wp-block-paragraph">paper here i&#8217;m just going to start drawing a graph remember graphs are nodes and edges where</p>



<p class="wp-block-paragraph">the nodes are like little t-type data structures that can hold a specific type of value um so i&#8217;m</p>



<p class="wp-block-paragraph">going to say our our nodes hold integers um i think i made that one too small that&#8217;s okay</p>



<p class="wp-block-paragraph">and the edges uh could have weights or maybe not weights at all depending on if you have</p>



<p class="wp-block-paragraph">a weighted or an unweighted graph so i&#8217;m just going to start duplicating my nodes a little bit</p>



<p class="wp-block-paragraph">going to make a random graph. I need to probably change these values. Technically your graphs</p>



<p class="wp-block-paragraph">should support duplicate values in the nodes and also the weights, but I don&#8217;t want to because</p>



<p class="wp-block-paragraph">it&#8217;s easier to talk about the graph when all the values are distinct. So for starters, we have a</p>



<p class="wp-block-paragraph">bunch of nodes and they&#8217;re not really connected to each other. Is this a valid graph? Yeah it is.</p>



<p class="wp-block-paragraph">It&#8217;s just not a connected graph. So the terminology that we&#8217;re going to use for</p>



<p class="wp-block-paragraph">undirected graphs meaning the edges don&#8217;t have direction is going to be connected or not you</p>



<p class="wp-block-paragraph">know i usually just say a not connected graph or a disconnected graph so just basically like</p>



<p class="wp-block-paragraph">connected or not connected okay so this is a not connected graph i&#8217;m going to say not connected</p>



<p class="wp-block-paragraph">not cinnamon i&#8217;m thinking about food as usual</p>



<p class="wp-block-paragraph">connected graph why is it not a connected graph well to define what does it mean to be a connected</p>



<p class="wp-block-paragraph">graph it just means that every single node can find a path to every single other node</p>



<p class="wp-block-paragraph">in an undirected graph so we can just double check this real fast we can say you know can</p>



<p class="wp-block-paragraph">node number two find a path to uh you know let me put a question here let&#8217;s say we&#8217;re going to check</p>



<p class="wp-block-paragraph">you should be checking all the nodes one by one by one to see if if the node in particular can</p>



<p class="wp-block-paragraph">first node that can&#8217;t do it means the whole graph is not considered connected so you know two it</p>



<p class="wp-block-paragraph">can&#8217;t reach one so that means it&#8217;s not a connected graph so this is not a connected graph because one</p>



<p class="wp-block-paragraph">or more nodes violate the rule of you have to be able to reach every single other node okay so that</p>



<p class="wp-block-paragraph">means if we want a connected graph we probably just have to start adding edges so I&#8217;m going to</p>



<p class="wp-block-paragraph">go ahead and uh let me let me write the word connected here and then I can like either circle</p>



<p class="wp-block-paragraph">cross it out. So right now we have no, this is not a connected graph. I&#8217;m going to start adding</p>



<p class="wp-block-paragraph">edges. We&#8217;re going to stick with an undirected graph for now. So I&#8217;m going to connect two and one</p>



<p class="wp-block-paragraph">and two and nine, maybe one and 13. Actually, you know what? I&#8217;m going to erase this edge</p>



<p class="wp-block-paragraph">and maybe connect these over here. And the thing is, this is a valid graph that you&#8217;re looking at.</p>



<p class="wp-block-paragraph">it&#8217;s just not a connected graph.</p>



<p class="wp-block-paragraph">Some other terminology I didn&#8217;t mention in other videos</p>



<p class="wp-block-paragraph">is that we can have subgraphs.</p>



<p class="wp-block-paragraph">We have like a subgraph here and another subgraph here.</p>



<p class="wp-block-paragraph">Those are basically just two different portions of the same graph</p>



<p class="wp-block-paragraph">that appear to be connected within themselves.</p>



<p class="wp-block-paragraph">So those are subgraphs.</p>



<p class="wp-block-paragraph">You can probably tell right away that this is not a connected graph.</p>



<p class="wp-block-paragraph">You can double check to be sure.</p>



<p class="wp-block-paragraph">You know, it&#8217;s good to do things the hard way</p>



<p class="wp-block-paragraph">so you don&#8217;t get the wrong answer</p>



<p class="wp-block-paragraph">when you&#8217;re really trying to figure something out.</p>



<p class="wp-block-paragraph">So let&#8217;s look at two.</p>



<p class="wp-block-paragraph">So let&#8217;s look at two. Can two reach one? Yes. So that&#8217;s good. Can two reach nine? Yeah,</p>



<p class="wp-block-paragraph">it just hops to one and then hops to nine. So two can reach one and also nine. That&#8217;s good.</p>



<p class="wp-block-paragraph">Can two reach three? Nope. So this is still not a connected graph.</p>



<p class="wp-block-paragraph">Okay, I&#8217;m going to add one more edge. And then we&#8217;ll just check again.</p>



<p class="wp-block-paragraph">Where do you think I&#8217;m going to do it? Maybe if I add, I&#8217;ll add a funky edge going from 13 to like</p>



<p class="wp-block-paragraph">to like nine or something just so it feels a little bit more awkward okay let&#8217;s check one by</p>



<p class="wp-block-paragraph">one by one let me actually get rid of this edge on the previous slide so we can still say that&#8217;s</p>



<p class="wp-block-paragraph">not connected let&#8217;s check one by one by one every node must be able to reach every single other</p>



<p class="wp-block-paragraph">node so I&#8217;m gonna look at two and I&#8217;m gonna say all right two can it reach one yes can it reach</p>



<p class="wp-block-paragraph">to nine. So that&#8217;s good. Can it reach three? Yeah, it can go from two to one to nine to 13</p>



<p class="wp-block-paragraph">to three, and then it can reach three. And because we just saw that it went through 13 to reach three,</p>



<p class="wp-block-paragraph">that means two can reach every single other node. This is going to be more important as a double</p>



<p class="wp-block-paragraph">check when we have directed graphs in a second. So two is good. So the next thing you want to do is</p>



<p class="wp-block-paragraph">the next thing you want to do is just move on to some other node and do the exact same process you</p>



<p class="wp-block-paragraph">know can can nine reach a one yes okay it can reach a one can it reach a two yeah it goes through</p>



<p class="wp-block-paragraph">the one can it reach the 13 yep can it reach the three yep okay so we just check every single</p>



<p class="wp-block-paragraph">destination node starting at the node nine but here&#8217;s a little bit of a shortcut try to find a</p>



<p class="wp-block-paragraph">node that is right next to a node that you know can reach everything and if the node in question</p>



<p class="wp-block-paragraph">that previously connected node, vertex,</p>



<p class="wp-block-paragraph">then we know that that node in particular is also connected.</p>



<p class="wp-block-paragraph">So what I&#8217;m saying is the one,</p>



<p class="wp-block-paragraph">instead of checking every single other node in the graph,</p>



<p class="wp-block-paragraph">which might be really hard</p>



<p class="wp-block-paragraph">if we have a whole bunch of nodes in our graph,</p>



<p class="wp-block-paragraph">we&#8217;ll just ask, can the one reach the two?</p>



<p class="wp-block-paragraph">Because if it can, the two can reach everything.</p>



<p class="wp-block-paragraph">So that means the one actually can reach everything as well.</p>



<p class="wp-block-paragraph">So the one can reach the two.</p>



<p class="wp-block-paragraph">So the one is connected to everything.</p>



<p class="wp-block-paragraph">the three, the three can reach the one and the one can reach everything. I&#8217;m doing things the</p>



<p class="wp-block-paragraph">hard way on purpose just to prove a point. So the three can reach everything. The 13 can reach the</p>



<p class="wp-block-paragraph">three in one hop. So the 13 can reach everything. The nine, it can reach the one and it can reach</p>



<p class="wp-block-paragraph">the 13 in one hop. So the nine can also actually reach everything. So that means this is indeed a</p>



<p class="wp-block-paragraph">the next thing that we&#8217;re going to do is add direction to our graph you know we could do like</p>



<p class="wp-block-paragraph">more examples maybe leave a comment if you want me to do some super extra complicated examples for</p>



<p class="wp-block-paragraph">just a undirected and connected graph i&#8217;m ignoring weight by the way because it doesn&#8217;t really matter</p>



<p class="wp-block-paragraph">for these purposes so let&#8217;s upgrade our graph so uh maybe i should put a question mark here</p>



<p class="wp-block-paragraph">that would have been a good idea we&#8217;re just asking you know is it connected or not</p>



<p class="wp-block-paragraph">And I&#8217;m just going to start adding direction to every single edge.</p>



<p class="wp-block-paragraph">Let&#8217;s see if I&#8217;m following my notes.</p>



<p class="wp-block-paragraph">Single node, subgraphs, right?</p>



<p class="wp-block-paragraph">Well, it wasn&#8217;t connected at first and then we started adding.</p>



<p class="wp-block-paragraph">Okay, so that&#8217;s basically okay.</p>



<p class="wp-block-paragraph">Let&#8217;s add direction to every single edge.</p>



<p class="wp-block-paragraph">So every single edge has to have a direction</p>



<p class="wp-block-paragraph">or every single edge has to have no direction.</p>



<p class="wp-block-paragraph">You can&#8217;t really mix and match.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to go through every single edge and add a direction like this.</p>



<p class="wp-block-paragraph">and you know to be fair I think I&#8217;ve said this in my other videos an undirected edge is kind of the</p>



<p class="wp-block-paragraph">same thing as a directed edge going in or two directed edges going in both directions so this</p>



<p class="wp-block-paragraph">3 and 13 what&#8217;s going on with my computer hello this 3 and 13 edge it would have kind of been the</p>



<p class="wp-block-paragraph">same as just having two edges going in opposite directions so maybe I&#8217;ll just do that right now</p>



<p class="wp-block-paragraph">for this huge weird edge I&#8217;m just going to put like an arrow over here instead of totally redrawing</p>



<p class="wp-block-paragraph">Then I double check that every single edge has a direction so that I have a valid graph.</p>



<p class="wp-block-paragraph">And now I can ask, is this connected or not?</p>



<p class="wp-block-paragraph">Actually, when it comes to a directed graph, you don&#8217;t really have connected or not anymore.</p>



<p class="wp-block-paragraph">You have strongly connected versus weakly connected.</p>



<p class="wp-block-paragraph">Maybe I should just separate these words and then just kind of like move them.</p>



<p class="wp-block-paragraph">So let&#8217;s get rid of this.</p>



<p class="wp-block-paragraph">to this save this over here move it down so what am i talking about um well first let me remove an</p>



<p class="wp-block-paragraph">edge real quick i&#8217;ll remove this edge right here so now we have two sub graphs in this graph you</p>



<p class="wp-block-paragraph">can tell for sure if this was an undirected graph it would not be connected but now that we&#8217;re</p>



<p class="wp-block-paragraph">dealing with direction we have to ask is it strongly connected versus weakly so what does</p>



<p class="wp-block-paragraph">can every node reach every other node if you obey the direction of the edges so that&#8217;s clearly not</p>



<p class="wp-block-paragraph">true there&#8217;s no edge at all that even connects this one and nine so it&#8217;s definitely not strongly</p>



<p class="wp-block-paragraph">connected weakly connected on the other hand means if you temporarily ignore the direction</p>



<p class="wp-block-paragraph">of the edges then could you consider the graph connected so if we pretended that there were no</p>



<p class="wp-block-paragraph">arrows here would we think that it&#8217;s a connected graph if the answer is yes then it&#8217;s at least a</p>



<p class="wp-block-paragraph">So this is not weakly connected because if this was an undirected graph, it&#8217;s not even connected at all.</p>



<p class="wp-block-paragraph">So that sucks.</p>



<p class="wp-block-paragraph">I&#8217;m going to go ahead and add another edge here.</p>



<p class="wp-block-paragraph">So I&#8217;m going to add an edge from 2 to 9.</p>



<p class="wp-block-paragraph">So the first thing is, oh, sorry, I have to add another edge.</p>



<p class="wp-block-paragraph">Let me do from 1 to 13 for fun.</p>



<p class="wp-block-paragraph">So now the first thing is, let&#8217;s check to see if this is a strongly connected graph.</p>



<p class="wp-block-paragraph">node is unreachable by any other node so this is definitely not strongly</p>



<p class="wp-block-paragraph">connected because all the other nodes would be would have to be able to reach</p>



<p class="wp-block-paragraph">too alright so first thing you could do just to very quickly check is just look</p>



<p class="wp-block-paragraph">at every single node and ask is it reachable you know by anything and then</p>



<p class="wp-block-paragraph">after that you can do things the hard way so it&#8217;s not strongly connected what</p>



<p class="wp-block-paragraph">about weakly connected if we ignore the direction of the graph sorry if we</p>



<p class="wp-block-paragraph">then yeah, we could reach every single node from every other node. Let&#8217;s just double check that</p>



<p class="wp-block-paragraph">real fast. I&#8217;m going to say, you know, the two node, if we&#8217;re ignoring direction, can it reach</p>



<p class="wp-block-paragraph">the one? Yes. Can it reach the 13? Yes. The three? Yes. Can it reach the nine? Yes. So that means the</p>



<p class="wp-block-paragraph">two node is sort of like weakly connected to every other node in the graph. Do the same thing for the</p>



<p class="wp-block-paragraph">one node. Previously, we just said, you know, check everything one by one or use a shortcut.</p>



<p class="wp-block-paragraph">one by one or use a shortcut. So I&#8217;m going to use the shortcut. The one node, if we ignore direction</p>



<p class="wp-block-paragraph">can reach the two nodes. So I&#8217;m going to say the one is weakly connected, at least everything else.</p>



<p class="wp-block-paragraph">I&#8217;m not even going to check to see if it&#8217;s strongly connected to everything else. I think the answer</p>



<p class="wp-block-paragraph">is no, but we do the same thing for the 13. The 13 can reach the one pretty fast. The three can</p>



<p class="wp-block-paragraph">reach the 13. The nine can reach the two. So every single node can weakly reach. That&#8217;s not an</p>



<p class="wp-block-paragraph">a weakly connected graph. Okay, cool. How can we make this a strongly connected graph? Well,</p>



<p class="wp-block-paragraph">we just have to add a bunch of edges. So that&#8217;s what I&#8217;m going to do. I&#8217;m going to kind of like</p>



<p class="wp-block-paragraph">look at what is missing here. So we&#8217;ll ask the two, can the two reach and let&#8217;s obey the direction</p>



<p class="wp-block-paragraph">of the edges again. Can the two reach the one? Yes. Can the two reach the 13? Yes. Can it reach</p>



<p class="wp-block-paragraph">Yes, so that means right now the two is strongly connected to everything else.</p>



<p class="wp-block-paragraph">So we&#8217;re on track for a strongly connected graph.</p>



<p class="wp-block-paragraph">We then look at the one node and we realize that the one node,</p>



<p class="wp-block-paragraph">it can reach the 13 and the three and it can also reach the nine,</p>



<p class="wp-block-paragraph">but it can&#8217;t reach the two.</p>



<p class="wp-block-paragraph">That&#8217;s one thing that was blocking us last time from saying strongly connected.</p>



<p class="wp-block-paragraph">So we just have to add another edge if we want this to be a strongly connected graph.</p>



<p class="wp-block-paragraph">We have to figure out how can we get the one to reach the two.</p>



<p class="wp-block-paragraph">the 2 we can go through something if we want to that&#8217;s fine we can also just</p>



<p class="wp-block-paragraph">write an edge that just goes back to the 2 but that&#8217;s I don&#8217;t know that&#8217;s kind of</p>



<p class="wp-block-paragraph">boring I&#8217;m gonna make an edge that goes from 1 to 9 and then I&#8217;m gonna make an</p>



<p class="wp-block-paragraph">edge that goes from 9 to 2 so looking at the 1 node it can now reach the 2 if we</p>



<p class="wp-block-paragraph">go through the 9 so that&#8217;s good can the 1 reach the 9 yes can the 1 reach the 13</p>



<p class="wp-block-paragraph">three yes okay so the one node can now reach every single other node so now we&#8217;re a little bit more</p>



<p class="wp-block-paragraph">on track for a strongly connected graph look at the 13 node can it reach the one node um actually</p>



<p class="wp-block-paragraph">yes if we go from 13 to 9 and then 2 and then 1 we can reach the one node since we know the one</p>



<p class="wp-block-paragraph">node is connected to everything else we can now say that the 13 node is connected to everything</p>



<p class="wp-block-paragraph">13 so i&#8217;ll say three is connected to everything the nine node can reach the two node which is</p>



<p class="wp-block-paragraph">connected to everything so that means the nine node is also connected to everything and at this</p>



<p class="wp-block-paragraph">point we now have a strongly connected graph it&#8217;s not weakly connected it&#8217;s stronger than that</p>



<p class="wp-block-paragraph">any questions um so let&#8217;s see we added a bunch of uh edges i think maybe this is actually all we</p>



<p class="wp-block-paragraph">need to do for this particular video because we&#8217;re just going to talk about connectedness</p>



<p class="wp-block-paragraph">going to talk about connectedness about 15 minutes not too bad all right so i think i&#8217;m</p>



<p class="wp-block-paragraph">going to leave it here drop a comment if you want to do way more complicated examples if you want to</p>



<p class="wp-block-paragraph">provide me a sample graph that&#8217;s awful and i could just i don&#8217;t know in the sometime in the future i</p>



<p class="wp-block-paragraph">could record a video about it um or just let me know your thoughts thank you so much for watching</p>



<p class="wp-block-paragraph">this video i hope you had a little bit of fun and i hope you learned a little bit of stuff i&#8217;m outie</p>



<p class="wp-block-paragraph">Patowdy.</p>



<p class="wp-block-paragraph">Alright, let&#8217;s see.</p>



<p class="wp-block-paragraph">I&#8217;m going to do this.</p>



<p class="wp-block-paragraph">Whoa. Can you see that guy in the background?</p>



<p class="wp-block-paragraph">Oh, shoot.</p>



<p class="wp-block-paragraph">I&#8217;m just kidding.</p>



<p class="wp-block-paragraph">I set that as the screensaver.</p>



<p class="wp-block-paragraph">Hey, everybody.</p>



<p class="wp-block-paragraph">Thanks for watching this video again from the bottom of my heart.</p>



<p class="wp-block-paragraph">I really appreciate it.</p>



<p class="wp-block-paragraph">I do hope you did learn something and have some fun.</p>



<p class="wp-block-paragraph">If you could do me a please, a small little favor,</p>



<p class="wp-block-paragraph">please subscribe and follow this channel or these videos or whatever it is you do on the current</p>



<p class="wp-block-paragraph">social media website that you&#8217;re looking at right now. It would really mean the world to me and it&#8217;ll</p>



<p class="wp-block-paragraph">help make more videos and grow this community. So we&#8217;ll be able to do more videos, longer videos,</p>



<p class="wp-block-paragraph">better videos, or just I&#8217;ll be able to keep making videos in general. So please do me a kindness</p>



<p class="wp-block-paragraph">and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up</p>



<p class="wp-block-paragraph">or followed. It just wakes me up and I get filled with joy. That&#8217;s exactly what happens every single</p>



<p class="wp-block-paragraph">time. So you could do it as a nice favor to me or you could you could troll me if you want to just</p>



<p class="wp-block-paragraph">wake me up in the middle of the night. Just subscribe and then I&#8217;ll just wake up. I promise</p>



<p class="wp-block-paragraph">that&#8217;s what will happen. Also if you look at the middle of the screen right now you should see a</p>



<p class="wp-block-paragraph">QR code which you can scan in order to go to the website which I think is also named somewhere at</p>



<p class="wp-block-paragraph">the bottom of this video and it&#8217;ll take you to my main website where you can just kind of like see</p>



<p class="wp-block-paragraph">videos i published and the services and tutorials and things that i offer and all that good stuff</p>



<p class="wp-block-paragraph">and uh if you have a suggestion for uh uh clarifications or errata or just future videos</p>



<p class="wp-block-paragraph">that you want to see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on</p>



<p class="wp-block-paragraph">you know just send me a comment whatever i also wake up for those in the middle of the night i get</p>



<p class="wp-block-paragraph">i wake up in a cold sweat and i&#8217;m like it would really it really mean the world to me i would</p>



<p class="wp-block-paragraph">it so again thank you so much for watching this video and enjoy the cool</p>



<p class="wp-block-paragraph">music as as I fade into the darkness which is coming for us all</p>



<p class="wp-block-paragraph">Thank you.</p>



<p class="wp-block-paragraph">so</p>



<p class="wp-block-paragraph">I&#8217;m going to go ahead and get started.</p>



<p class="wp-block-paragraph">so</p>



<p class="wp-block-paragraph">Yeah, I think I&#8217;m good.</p>



<p class="wp-block-paragraph">Hello there.</p>



<p class="wp-block-paragraph">Let&#8217;s talk about whether a graph is connected or not,</p>



<p class="wp-block-paragraph">or maybe whether it&#8217;s strongly connected or weakly connected or not connected at all.</p>



<p class="wp-block-paragraph">You never know.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/">Graph Connectedness Explained: Connected Strongly Connected and Weakly Connected</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/graph-connectedness-explained-connected-strongly-connected-and-weakly-connected/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Graph Basics in Data Structures: Nodes, Edges, and Representations</title>
		<link>https://www.NeuralLantern.com/graph-basics-in-data-structures-nodes-edges-and-representations/</link>
					<comments>https://www.NeuralLantern.com/graph-basics-in-data-structures-nodes-edges-and-representations/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Tue, 14 Jul 2026 22:43:47 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[adjacency list]]></category>
		<category><![CDATA[adjacency matrix]]></category>
		<category><![CDATA[C++ graph tutorial]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[data structures tutorial]]></category>
		<category><![CDATA[directed graph]]></category>
		<category><![CDATA[edge list]]></category>
		<category><![CDATA[graph data structure]]></category>
		<category><![CDATA[graph representations]]></category>
		<category><![CDATA[graph terminology]]></category>
		<category><![CDATA[graphs computer science]]></category>
		<category><![CDATA[nodes and edges]]></category>
		<category><![CDATA[undirected graph]]></category>
		<category><![CDATA[weighted graph]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=412</guid>

					<description><![CDATA[<p>Graphs are collections of nodes and edges, or vertices and edges. In this tutorial we implement them as template classes in C++ so you can use custom data types for nodes and edge weights. We cover undirected unweighted graphs, then add directions and weights to show path costs between cities or network nodes.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-basics-in-data-structures-nodes-edges-and-representations/">Graph Basics in Data Structures: Nodes, Edges, and Representations</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Graph Basics in Data Structures: Nodes, Edges, and Representations" width="1380" height="776" src="https://www.youtube.com/embed/bz7VFYnTTQQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Learn graph basics: nodes, edges, neighbors, adjacency. Undirected vs directed, unweighted vs weighted. Representations including edge list, adjacency list, and matrix. Great intro for computer science students.</p>



<p class="wp-block-paragraph">00:00 Graph Basics Introduction<br>00:41 Nodes and Edges<br>01:20 Node and Edge Classes in C++<br>03:46 Simple Graph Examples<br>04:29 Adding Edges &#8211; Undirected Unweighted<br>05:26 Real World Uses of Graphs<br>07:08 Graph Terminology &#8211; Neighbors and Adjacency<br>08:32 Edges Incident on Nodes<br>09:20 Graph Representations &#8211; Edge List<br>09:59 Adjacency List<br>10:27 Adjacency Matrix<br>11:19 Directed Graphs<br>13:04 Weighted Graphs and Path Costs<br>15:24 Video Conclusion</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p class="wp-block-paragraph">Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hello there. Let&#8217;s talk about graphs in the context of data structures and computer science.</p>



<p class="wp-block-paragraph">I just want to talk to you about some of the basics of graphs, some ways that we could</p>



<p class="wp-block-paragraph">implement them in the future, and some terminology. Okay, so for starters, we have a little</p>



<p class="wp-block-paragraph">For starters, we have a little blank graph sheet here.</p>



<p class="wp-block-paragraph">If you saw my previous video, you&#8217;ll know already that this is a valid graph.</p>



<p class="wp-block-paragraph">It&#8217;s just totally empty.</p>



<p class="wp-block-paragraph">There&#8217;s nothing on it.</p>



<p class="wp-block-paragraph">But let me draw some data in this graph.</p>



<p class="wp-block-paragraph">So graphs are collections of nodes and edges, or vertices and edges, or vertex and edges.</p>



<p class="wp-block-paragraph">The nodes themselves, they are custom classes sometimes, other times not.</p>



<p class="wp-block-paragraph">But you can imagine that they hold some sort of custom data.</p>



<p class="wp-block-paragraph">of custom data so i know i did this in my last video but i just want to emphasize that this graph</p>



<p class="wp-block-paragraph">class if we&#8217;re talking about c plus plus it should be a template class meaning we can specify a</p>



<p class="wp-block-paragraph">custom data type that the nodes will hold and also a custom data type that the edges will have as</p>



<p class="wp-block-paragraph">their weight you know typically when you see examples of this in the wild it&#8217;s just going to</p>



<p class="wp-block-paragraph">floats and strings exotic custom classes depending on your use case it may or may not be useful to do</p>



<p class="wp-block-paragraph">that but so we&#8217;ll have a data type for our nodes and i&#8217;ll call it like n type for like our node</p>



<p class="wp-block-paragraph">type and then we&#8217;ll do another one called e type for edge type i don&#8217;t know if that&#8217;s the best way</p>



<p class="wp-block-paragraph">to write those but i&#8217;m just going to do it anyway imagine that your glass your graph like we said</p>



<p class="wp-block-paragraph">So I&#8217;m going to put a node class here.</p>



<p class="wp-block-paragraph">You can imagine this as a vertex class.</p>



<p class="wp-block-paragraph">And I&#8217;m going to say that this node holds an n type data.</p>



<p class="wp-block-paragraph">And we&#8217;ll just call it data or node value or whatever you want.</p>



<p class="wp-block-paragraph">And then the same thing for the edges.</p>



<p class="wp-block-paragraph">We&#8217;ll say we have an edge class.</p>



<p class="wp-block-paragraph">I think in my last video, instead of doing a node class, I did a vertex class.</p>



<p class="wp-block-paragraph">It&#8217;s kind of all the same.</p>



<p class="wp-block-paragraph">We&#8217;ll say we have an e type and we&#8217;ll call it weight or value or data if you want.</p>



<p class="wp-block-paragraph">or value or data if you want but I think weight is a little bit closer to what we&#8217;re going to</p>



<p class="wp-block-paragraph">actually be doing with it and what do I mean by n type and e type like what are those data types</p>



<p class="wp-block-paragraph">there that just means these are placeholder tokens so when the user actually uses your graph by</p>



<p class="wp-block-paragraph">making an instance of your graph class like they create an actual graph off of your blueprint</p>



<p class="wp-block-paragraph">class here they might decide that they want integers inside of their nodes so that&#8217;s what</p>



<p class="wp-block-paragraph">They might decide that they want floats inside of your nodes, inside of their nodes, or some</p>



<p class="wp-block-paragraph">other data type.</p>



<p class="wp-block-paragraph">And so that means like at runtime or at, I think actually at compile time for C++, this</p>



<p class="wp-block-paragraph">end type would actually change to int if they chose to use integers on the inside.</p>



<p class="wp-block-paragraph">Same thing would happen for the edge, whatever they choose for the E-type token is just going</p>



<p class="wp-block-paragraph">to end up being used at compile time to replace that E-type.</p>



<p class="wp-block-paragraph">So I don&#8217;t know.</p>



<p class="wp-block-paragraph">Here&#8217;s an example.</p>



<p class="wp-block-paragraph">example, I got a fly in my room, it&#8217;s bothering me. Imagine the user says I want a graph.</p>



<p class="wp-block-paragraph">And I&#8217;ll call it G. And so they just have to kind of specify the two data types, maybe they want the</p>



<p class="wp-block-paragraph">graph to have integer values in the nodes. And maybe, you know, floating point double precision</p>



<p class="wp-block-paragraph">floating point values on the edges. In terms of weights, you know, you could do something like</p>



<p class="wp-block-paragraph">And we have edges and this graph right here is valid.</p>



<p class="wp-block-paragraph">It&#8217;s just one node kind of floating around by itself.</p>



<p class="wp-block-paragraph">This graph is also still valid, even though we have two nodes that are floating unconnected</p>



<p class="wp-block-paragraph">and also with the same value.</p>



<p class="wp-block-paragraph">I&#8217;m just going to change the value to be different.</p>



<p class="wp-block-paragraph">Maybe I&#8217;ll get rid of this extra thing here.</p>



<p class="wp-block-paragraph">So this is a valid graph still.</p>



<p class="wp-block-paragraph">We could have like a whole bunch of nodes all over the place and they don&#8217;t really have</p>



<p class="wp-block-paragraph">to be connected.</p>



<p class="wp-block-paragraph">This is still a valid graph.</p>



<p class="wp-block-paragraph">change this to like a three, maybe change this to like an 11, change that to a six.</p>



<p class="wp-block-paragraph">What else can I change?</p>



<p class="wp-block-paragraph">How about like a 13?</p>



<p class="wp-block-paragraph">How about like a 17?</p>



<p class="wp-block-paragraph">Are there any duplicates?</p>



<p class="wp-block-paragraph">I don&#8217;t think I see any.</p>



<p class="wp-block-paragraph">All right.</p>



<p class="wp-block-paragraph">So this is a valid graph.</p>



<p class="wp-block-paragraph">The next thing that we could add to our graph is edges.</p>



<p class="wp-block-paragraph">So edges are, you know, little mini data structures that connect nodes.</p>



<p class="wp-block-paragraph">In this particular graph, I&#8217;m choosing to not have direction on my edges, which means this is a special type of graph.</p>



<p class="wp-block-paragraph">Or four that we talked about in the previous video.</p>



<p class="wp-block-paragraph">This is unweighted and also undirected, meaning there&#8217;s no weight assigned to the edges,</p>



<p class="wp-block-paragraph">which means that template weight value or the weight data type that we just talked about before.</p>



<p class="wp-block-paragraph">It&#8217;s kind of useless for this particular graph because I&#8217;m saying it&#8217;s unweighted.</p>



<p class="wp-block-paragraph">well uh all the edges if we wanted to travel through the graph along the edges we could just</p>



<p class="wp-block-paragraph">sort of go in any direction we felt like so this is unweighted and undirected</p>



<p class="wp-block-paragraph">um let&#8217;s see what else can i show you real fast okay so let&#8217;s talk about um well really fast let&#8217;s</p>



<p class="wp-block-paragraph">talk about the uses that you can have for a graph i think i talked about this in the last video</p>



<p class="wp-block-paragraph">but um you know what can we use graphs for some people think they&#8217;re databases they&#8217;re not really</p>



<p class="wp-block-paragraph">They&#8217;re not really databases.</p>



<p class="wp-block-paragraph">You could technically do that, but it would be pretty slow.</p>



<p class="wp-block-paragraph">There are much better data structures for databases.</p>



<p class="wp-block-paragraph">Really what graphs are mostly used for is to represent relationships between different</p>



<p class="wp-block-paragraph">things.</p>



<p class="wp-block-paragraph">I think I said this in the last video.</p>



<p class="wp-block-paragraph">Imagine if every single node that you see here is a city and the edges represent flight</p>



<p class="wp-block-paragraph">paths.</p>



<p class="wp-block-paragraph">So we could fly between city seven and 11.</p>



<p class="wp-block-paragraph">Oh, that&#8217;s funny.</p>



<p class="wp-block-paragraph">I&#8217;m hungry for candy bar now.</p>



<p class="wp-block-paragraph">between city seven and 11 and back and you know back in the other direction if we want to but we</p>



<p class="wp-block-paragraph">can&#8217;t actually fly from city seven to six because there&#8217;s no edge there so we could represent</p>



<p class="wp-block-paragraph">computer networks we could represent road maps airports dependency graphs game maps you could</p>



<p class="wp-block-paragraph">say like every node is somewhere your character could stand and an edge represents where your</p>



<p class="wp-block-paragraph">or represents a connection to another node so that you know your character could move there</p>



<p class="wp-block-paragraph">there&#8217;s all sorts of different things that you could represent with the graph but</p>



<p class="wp-block-paragraph">it&#8217;s not necessarily a fast database it&#8217;s more of like a relationship</p>



<p class="wp-block-paragraph">not to be confused with relational database which is supposed to be lightning fast</p>



<p class="wp-block-paragraph">like if i wanted to search for the number 17 in this graph it&#8217;s not going to be log time like a</p>



<p class="wp-block-paragraph">proper database should be it&#8217;s not going to be constant time like a hash table based database</p>



<p class="wp-block-paragraph">or like a no sql or whatever um so we have undirected and unweighted uh we talked about</p>



<p class="wp-block-paragraph">like different uses let&#8217;s talk a little bit about terminology okay for starters notice how there&#8217;s</p>



<p class="wp-block-paragraph">no hierarchy in this graph in other videos we&#8217;re going to talk about binary search trees and we</p>



<p class="wp-block-paragraph">have to have like a hierarchy there&#8217;s no parent there&#8217;s no child in these graphs there&#8217;s no uh</p>



<p class="wp-block-paragraph">you know like grandchildren ancestors descendants because there&#8217;s not really like a hierarchy it&#8217;s</p>



<p class="wp-block-paragraph">It&#8217;s just things are connected to each other or they&#8217;re not.</p>



<p class="wp-block-paragraph">But we can have something called neighbors.</p>



<p class="wp-block-paragraph">For example, if you can reach a node in one hop, then you might be able to call that a neighbor.</p>



<p class="wp-block-paragraph">So 6 and 17, those are neighbors.</p>



<p class="wp-block-paragraph">Maybe I&#8217;ll just type neighbors right here.</p>



<p class="wp-block-paragraph">Oops, neighbors.</p>



<p class="wp-block-paragraph">Because we can reach them in one hop.</p>



<p class="wp-block-paragraph">Later on, or especially if I don&#8217;t remember to mention this,</p>



<p class="wp-block-paragraph">to our graph, then something is only considered a neighbor if you can reach it while respecting</p>



<p class="wp-block-paragraph">the direction of the graph. So we have like neighbors as 6 and 17. So that means 6 and 11</p>



<p class="wp-block-paragraph">are also neighbors. 6 and 12, not neighbors because they can&#8217;t reach each other in one hop.</p>



<p class="wp-block-paragraph">Let&#8217;s see. Adjacency is basically the same thing. I can&#8217;t remember. I think we use adjacency more</p>



<p class="wp-block-paragraph">often in directed graphs, but we could say that 6 and 17 are adjacent to each other,</p>



<p class="wp-block-paragraph">adjacent to each other, which is in this context, sort of a synonym for neighbors.</p>



<p class="wp-block-paragraph">Okay. Something else that I want to talk about in terms of edges,</p>



<p class="wp-block-paragraph">edges are considered to be incident upon nodes or vertices. So like, you know,</p>



<p class="wp-block-paragraph">if I have an arrow that just kind of points to these two things, I could say,</p>



<p class="wp-block-paragraph">you know, edge is incident upon three and 12. It&#8217;s just, it just means,</p>



<p class="wp-block-paragraph">and 12th. Okay, what else should we talk about? We should talk about connected versus, no,</p>



<p class="wp-block-paragraph">that&#8217;s another video. Okay, I&#8217;m going to do another video for connected versus not connected graphs.</p>



<p class="wp-block-paragraph">Maybe I should mention that there are three ways that we can represent a graph, and then maybe I&#8217;ll</p>



<p class="wp-block-paragraph">upgrade to a directed graph in a second. If you want to know about the four different types of</p>



<p class="wp-block-paragraph">graphs, see my previous video. But for now, I&#8217;m going to say there are three ways we could</p>



<p class="wp-block-paragraph">to represent these graphs. The first way, and I&#8217;m talking about how can you represent these</p>



<p class="wp-block-paragraph">graphs inside of the machine? Like how can your computer store and process this graph and maybe</p>



<p class="wp-block-paragraph">run algorithms on it? So the first way that we could represent, at least that I&#8217;m going to talk</p>



<p class="wp-block-paragraph">about, is an edge list. Edge lists are super simple. I&#8217;m going to do a dedicated video just</p>



<p class="wp-block-paragraph">for edge lists in the future. They&#8217;re not very fast, but they&#8217;re very easy to implement. So</p>



<p class="wp-block-paragraph">So honestly, if you&#8217;re just starting with this stuff, I would recommend just implementing an edge list first</p>



<p class="wp-block-paragraph">The next thing that you can do to represent a graph in the machine is make an adjacency list</p>



<p class="wp-block-paragraph">Adjacency lists are just a little bit more complicated</p>



<p class="wp-block-paragraph">But they&#8217;re typically faster than edge lists. Not always not in all cases and</p>



<p class="wp-block-paragraph">In terms of time complexity, you might not feel like you notice much of a difference</p>



<p class="wp-block-paragraph">but empirically</p>



<p class="wp-block-paragraph">the option of skipping a lot of examinations when you don&#8217;t need to examine something,</p>



<p class="wp-block-paragraph">you kind of skip it.</p>



<p class="wp-block-paragraph">We&#8217;ll talk more about that in the future.</p>



<p class="wp-block-paragraph">But we have an edge list and adjacency list of representation.</p>



<p class="wp-block-paragraph">And then we have an adjacency matrix.</p>



<p class="wp-block-paragraph">I wish I had spell check on this.</p>



<p class="wp-block-paragraph">Otherwise, this is going to be humiliating.</p>



<p class="wp-block-paragraph">An adjacency matrix is sometimes a lightning fast representation of a graph.</p>



<p class="wp-block-paragraph">At first, you might think, wow, that&#8217;s amazing.</p>



<p class="wp-block-paragraph">I&#8217;m always going to use that.</p>



<p class="wp-block-paragraph">always going to use that. But all of these representations have strengths and weaknesses.</p>



<p class="wp-block-paragraph">None of them are better than the others in every single circumstance. So, you know, computer science</p>



<p class="wp-block-paragraph">and data structures, it&#8217;s all about weighing the pros and cons and picking the right representation</p>



<p class="wp-block-paragraph">or algorithm or whatever that&#8217;s best for you and the code and the data that you&#8217;re actually going</p>



<p class="wp-block-paragraph">to run. So three different ways that we can represent a graph in the future. And let&#8217;s see,</p>



<p class="wp-block-paragraph">already on this. We talked about the basic ways to use them sort of. We talked about neighbors</p>



<p class="wp-block-paragraph">and adjacency. Oh, I got to upgrade to a directed graph real fast just to kind of show you the</p>



<p class="wp-block-paragraph">difference here. Okay, so I&#8217;m going to duplicate this and I&#8217;m just going to start adding direction</p>



<p class="wp-block-paragraph">to all my edges. In my previous video, we talked about this. If you add direction to even one edge,</p>



<p class="wp-block-paragraph">then you have to add direction to all the other edges. Otherwise, you will have an invalid graph.</p>



<p class="wp-block-paragraph">graph so notice how I add a direction to one edge I now have an invalid graph so</p>



<p class="wp-block-paragraph">I&#8217;m just gonna do this change every single edge so that every single edge</p>



<p class="wp-block-paragraph">has a direction you know the basic thing we kind of talked about this in my</p>



<p class="wp-block-paragraph">previous video is that when traveling through the graph you&#8217;re supposed to</p>



<p class="wp-block-paragraph">only be able to travel in the direction of an edge which means if you look at</p>



<p class="wp-block-paragraph">this thing right now you&#8217;re supposed to be able to go from 11 to 7 but you&#8217;re</p>



<p class="wp-block-paragraph">be able to go from 7 to 11 because that violates the direction of the edge. When we add direction</p>



<p class="wp-block-paragraph">we&#8217;re sort of like reducing you know the flexibility of the graph so you can imagine</p>



<p class="wp-block-paragraph">that the previous version that was undirected it was sort of like every single edge here</p>



<p class="wp-block-paragraph">was really two edges pointing in opposite directions if that makes sense. So if you</p>



<p class="wp-block-paragraph">wanted to make sure that you could go back and forth between edge sorry between node 7 and 11</p>



<p class="wp-block-paragraph">the opposite direction you can also do things called parallel edges which is just to say</p>



<p class="wp-block-paragraph">i&#8217;m going to add multiple edges that that go in the same direction from the same start node to</p>



<p class="wp-block-paragraph">the same end node but i&#8217;m not going to do that here that makes it more complicated for some</p>



<p class="wp-block-paragraph">representations but we can just sort of add a whole bunch of edges i&#8217;m just going to say one</p>



<p class="wp-block-paragraph">going back and forth there and so forth remember in my previous video we talked about weighted edges</p>



<p class="wp-block-paragraph">about weighted edges which means we could add a cost to traveling along an edge so you could say</p>



<p class="wp-block-paragraph">something like uh i don&#8217;t know going from 7 to 12 let&#8217;s add another edge here if there was a cost</p>



<p class="wp-block-paragraph">on all these weights maybe i should just add that for fun we could maybe calculate which path would</p>



<p class="wp-block-paragraph">be better so let&#8217;s say we got ones over here and we got fives over here um and maybe like a like</p>



<p class="wp-block-paragraph">and I&#8217;m going to do like an eight.</p>



<p class="wp-block-paragraph">By the way, these sixes don&#8217;t have to be the same.</p>



<p class="wp-block-paragraph">You could just be two different numbers.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do like a three here.</p>



<p class="wp-block-paragraph">And let me just see, have I added a weight to every single edge?</p>



<p class="wp-block-paragraph">So I know I did this in the previous video,</p>



<p class="wp-block-paragraph">but I want to do it again real fast.</p>



<p class="wp-block-paragraph">If we chose to take a path from seven to 12,</p>



<p class="wp-block-paragraph">and we said seven to 11, and then 11 to 12,</p>



<p class="wp-block-paragraph">that&#8217;s a very specific path, which is,</p>



<p class="wp-block-paragraph">it&#8217;s going to cost us five to go along that first,</p>



<p class="wp-block-paragraph">as you have to go along that first edge and then the second edge is going to cost us six</p>



<p class="wp-block-paragraph">and we&#8217;re only traveling along two edges so the total cost of that path is 11.</p>



<p class="wp-block-paragraph">On the other hand let me actually make this look pink.</p>



<p class="wp-block-paragraph">On the other hand if we&#8217;re taking a different path we might come up with a different cost</p>



<p class="wp-block-paragraph">depending on the graph. So let&#8217;s say we start at 11 start at 7 maybe we want to go down to 3</p>



<p class="wp-block-paragraph">to three and then from three we&#8217;ll go to 12 well that might be a different cost so i&#8217;m going to say</p>



<p class="wp-block-paragraph">the cost of this particular path is traveling it&#8217;s going to cost us one to go down that first edge</p>



<p class="wp-block-paragraph">and then a two to go down that second edge which means the total cost of getting to 12 is only 3</p>



<p class="wp-block-paragraph">if we take that orange path versus 11 if we take that pink path i hope you&#8217;re starting to visualize</p>



<p class="wp-block-paragraph">how graphs might be useful to visualize costs if this is a network map we just figured out that</p>



<p class="wp-block-paragraph">network map we just figured out that one route through the network might be faster or less</p>



<p class="wp-block-paragraph">costly than the other or if this is like an airport map maybe you do want to take you know</p>



<p class="wp-block-paragraph">that layover that goes down south instead of that layover that goes east in terms of</p>



<p class="wp-block-paragraph">i don&#8217;t know frequent fire miles that it costs you or money it costs you or jet fuel that it</p>



<p class="wp-block-paragraph">That&#8217;s all I wanted to talk about in this video.</p>



<p class="wp-block-paragraph">I&#8217;m going to make one more video today.</p>



<p class="wp-block-paragraph">Well, it&#8217;ll be released.</p>



<p class="wp-block-paragraph">I don&#8217;t know when, but like in my present moment.</p>



<p class="wp-block-paragraph">I&#8217;m going to make another video right after this</p>



<p class="wp-block-paragraph">where we just talk about connected graphs versus not connected graphs.</p>



<p class="wp-block-paragraph">Thank you so much for watching this video.</p>



<p class="wp-block-paragraph">I hope you learned a little bit of stuff and had a little bit of fun.</p>



<p class="wp-block-paragraph">See you in the future.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">In the future.</p>



<p class="wp-block-paragraph">in the future.</p>



<p class="wp-block-paragraph">So we&#8217;ll be able to do more videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general.</p>



<p class="wp-block-paragraph">So please do me a kindness and subscribe.</p>



<p class="wp-block-paragraph">You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.</p>



<p class="wp-block-paragraph">It just wakes me up and I get filled with joy.</p>



<p class="wp-block-paragraph">That&#8217;s exactly what happens every single time.</p>



<p class="wp-block-paragraph">So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.</p>



<p class="wp-block-paragraph">Just subscribe and then I&#8217;ll just wake up.</p>



<p class="wp-block-paragraph">I promise that&#8217;s what will happen.</p>



<p class="wp-block-paragraph">happen also if you look at the middle of the screen right now you should see a QR code which</p>



<p class="wp-block-paragraph">you can scan in order to go to the website which I think is also named somewhere at the bottom of</p>



<p class="wp-block-paragraph">this video and it&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p class="wp-block-paragraph">I published and the services and tutorials and things that I offer and all that good stuff and</p>



<p class="wp-block-paragraph">if you have a suggestion for clarifications or errata or just future videos that you want to</p>



<p class="wp-block-paragraph">videos that you want to see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s</p>



<p class="wp-block-paragraph">going on you know just send me a comment whatever i also wake up for those in the middle of the</p>



<p class="wp-block-paragraph">night i get i wake up in a cold sweat and i&#8217;m like it would really it really mean the world to me i</p>



<p class="wp-block-paragraph">would really appreciate it so again thank you so much for watching this video and um enjoy the cool</p>



<p class="wp-block-paragraph">so</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/graph-basics-in-data-structures-nodes-edges-and-representations/">Graph Basics in Data Structures: Nodes, Edges, and Representations</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/graph-basics-in-data-structures-nodes-edges-and-representations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>4 Graph Types: Undirected vs Directed, Weighted vs Unweighted</title>
		<link>https://www.NeuralLantern.com/4-graph-types-undirected-vs-directed-weighted-vs-unweighted/</link>
					<comments>https://www.NeuralLantern.com/4-graph-types-undirected-vs-directed-weighted-vs-unweighted/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 06 Jul 2026 10:05:07 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[binary search tree]]></category>
		<category><![CDATA[coding tutorial]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[directed graph]]></category>
		<category><![CDATA[edges]]></category>
		<category><![CDATA[graph theory]]></category>
		<category><![CDATA[graph types]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[network topology]]></category>
		<category><![CDATA[nodes]]></category>
		<category><![CDATA[pathfinding]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[undirected graph]]></category>
		<category><![CDATA[unweighted graph]]></category>
		<category><![CDATA[vertices]]></category>
		<category><![CDATA[weighted graph]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=407</guid>

					<description><![CDATA[<p>A graph is basically a collection of nodes, also known as vertices, and edges, which are the lines that connect nodes to each other. The four types of graphs are undirected unweighted, undirected weighted, directed unweighted, and directed weighted. Graphs help represent relationships between things like computers in a network or cities and airports.</p>
<p>The post <a href="https://www.NeuralLantern.com/4-graph-types-undirected-vs-directed-weighted-vs-unweighted/">4 Graph Types: Undirected vs Directed, Weighted vs Unweighted</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="4 Graph Types: Undirected vs Directed, Weighted vs Unweighted" width="1380" height="776" src="https://www.youtube.com/embed/8Ml20VhpdrI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">In this video we break down the four main types of graphs used in computer science: undirected unweighted, undirected weighted, directed unweighted, and directed weighted.</p>



<p class="wp-block-paragraph">We start with the basic idea of graphs &#8211; collections of nodes (vertices) and edges &#8211; and then explore each type with clear examples. Learn how these graphs represent real-world relationships like computer networks, airport routes, road maps, and game maps.</p>



<p class="wp-block-paragraph">Perfect for anyone learning data structures, algorithms, or preparing for coding interviews.</p>



<p class="wp-block-paragraph">00:00 Introduction to Graphs<br>00:19 Basic Graph Definition<br>00:48 Nodes and Vertices<br>01:01 Empty Graph Example<br>01:17 Graph Implementation Concepts<br>02:02 Node Data and Templates<br>03:22 Adding Nodes<br>04:00 Adding Edges<br>04:44 What Graphs Represent<br>05:36 Graph Use Cases<br>06:56 Real-World Examples<br>08:35 Four Types of Graphs<br>08:52 Undirected Unweighted Graph<br>10:40 Unweighted as Unit Weights<br>11:40 Undirected Weighted Graph<br>13:32 Weighted Graph Benefits<br>15:52 Directed Weighted Graph<br>19:50 Directed Unweighted Graph<br>20:32 Summary of Four Graph Types<br>21:19 Closing and Future Videos</p>



<p class="wp-block-paragraph">=-=-=-=-=-=-=-=-=</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>



<li>Twitter / X: https://x.com/NeuralLantern</li>



<li>Rumble: https://rumble.com/c/c-3696939</li>



<li>BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt</li>



<li>Daily Motion: https://www.dailymotion.com/neurallantern</li>



<li>Minds: https://www.minds.com/neurallantern/</li>



<li>Odysee: https://odysee.com/@NeuralLantern:5</li>
</ul>



<p class="wp-block-paragraph">Please show your support!</p>



<ul class="wp-block-list">
<li>Buy me a coffee: https://ko-fi.com/neurallantern</li>



<li>Subscribe + Sharing on Social Media</li>



<li>Leave a comment or suggestion</li>



<li>Subscribe to the Blog: https://www.NeuralLantern.com</li>



<li>Watch the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hello there! Let&#8217;s talk about four different types of graphs that you can use and how they relate to computer science.</p>



<p class="wp-block-paragraph">Okay, so you can see like I&#8217;ve got like a blank little graph paper up here.</p>



<p class="wp-block-paragraph">I&#8217;m going to talk about graphs and just the very basic idea of graphs in general</p>



<p class="wp-block-paragraph">and then show you the four different types of graphs that we have.</p>



<p class="wp-block-paragraph">about how to implement graphs inside the machine, time complexities, maybe graph algorithms,</p>



<p class="wp-block-paragraph">and a whole bunch of stuff, terminology, everything. Okay, so the first thing is, I guess I&#8217;m going to</p>



<p class="wp-block-paragraph">assume probably most of you have sort of seen a graph before and you kind of understand a little</p>



<p class="wp-block-paragraph">bit about it already, but I&#8217;ll say that a graph is basically a collection of nodes, also known as</p>



<p class="wp-block-paragraph">vertices or vertexes, and edges, which are the lines that connect nodes to each other. This screen</p>



<p class="wp-block-paragraph">See, this is a valid graph.</p>



<p class="wp-block-paragraph">I&#8217;m not talking about the graphing paper.</p>



<p class="wp-block-paragraph">It&#8217;s just an empty graph.</p>



<p class="wp-block-paragraph">There&#8217;s nothing there.</p>



<p class="wp-block-paragraph">So it&#8217;s still valid.</p>



<p class="wp-block-paragraph">It&#8217;s just blank.</p>



<p class="wp-block-paragraph">Okay, so then what I want to do is start drawing some nodes.</p>



<p class="wp-block-paragraph">What are the nodes again?</p>



<p class="wp-block-paragraph">Those are just vertices.</p>



<p class="wp-block-paragraph">Those are just like little data structure objects you can imagine in the code.</p>



<p class="wp-block-paragraph">I don&#8217;t want to get too far ahead of myself, but imagine that you have a class called graph.</p>



<p class="wp-block-paragraph">This is just one way to imagine.</p>



<p class="wp-block-paragraph">We have a class called graph and then a nested class inside of a graph called a node or a vertex</p>



<p class="wp-block-paragraph">If you want to be more fancy</p>



<p class="wp-block-paragraph">So the vertex class itself by the way</p>



<p class="wp-block-paragraph">This is not always going to be the way that you actually do this in your code the other representations that we&#8217;ll talk about sooner a little bit easier, but</p>



<p class="wp-block-paragraph">The vertex class itself needs to basically hold some data</p>



<p class="wp-block-paragraph">Depending on your implementation it might know about who it&#8217;s connected to maybe the graph knows that instead</p>



<p class="wp-block-paragraph">instead. In my implementations, the graph is going to know everything, but the vertex or the node</p>



<p class="wp-block-paragraph">itself needs to hold one piece of data. That&#8217;s kind of the whole point. So I&#8217;m going to say that</p>



<p class="wp-block-paragraph">the data type that these nodes hold are just integers. So I&#8217;m just going to put like a six in</p>



<p class="wp-block-paragraph">here just to indicate we have one node and the templated data type that it holds is an integer.</p>



<p class="wp-block-paragraph">And the specific integer for this specific node is just the number six. You can have any template</p>



<p class="wp-block-paragraph">any template type if you really want to you can people put floats in there you could put a custom</p>



<p class="wp-block-paragraph">custom class in there whatever you want but i just want to show you that we have a class called</p>



<p class="wp-block-paragraph">vertex or node and inside of it&#8217;s got a template type maybe just to make this a little bit more</p>



<p class="wp-block-paragraph">clear i&#8217;ll say you can imagine inside the vertex class uh there is a template type and we&#8217;ll call</p>



<p class="wp-block-paragraph">it uh i don&#8217;t know node node value type or something and we&#8217;ll call it data and then up</p>



<p class="wp-block-paragraph">I&#8217;m doing C++ up here.</p>



<p class="wp-block-paragraph">We have to kind of define the whole graph class as a template class.</p>



<p class="wp-block-paragraph">Now, of course, you could define the vertex class as the template class,</p>



<p class="wp-block-paragraph">but if you define the graph class as a template, then it all kind of falls through.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to say class node value type.</p>



<p class="wp-block-paragraph">And so if you&#8217;ve written template classes before in C++,</p>



<p class="wp-block-paragraph">now you know that the user can instance the graph and at the same time,</p>



<p class="wp-block-paragraph">specify what is the data type of the stuff that the nodes hold.</p>



<p class="wp-block-paragraph">the stuff that the nodes hold.</p>



<p class="wp-block-paragraph">We do the same thing for edges too,</p>



<p class="wp-block-paragraph">but notice how there are no nodes that are connected to each other.</p>



<p class="wp-block-paragraph">So we have no edges in this graph.</p>



<p class="wp-block-paragraph">This is still a valid graph,</p>



<p class="wp-block-paragraph">but we could just sort of copy a node just for fun and say,</p>



<p class="wp-block-paragraph">all right, we&#8217;ve got two nodes now, two vertices.</p>



<p class="wp-block-paragraph">They could have the same value if you want.</p>



<p class="wp-block-paragraph">Graphs are supposed to, you know, support duplicate values in the nodes,</p>



<p class="wp-block-paragraph">but I&#8217;m just going to change the value here.</p>



<p class="wp-block-paragraph">This is also a valid graph.</p>



<p class="wp-block-paragraph">You don&#8217;t really need edges to have a valid graph.</p>



<p class="wp-block-paragraph">edges to have a valid graph. This is just something called a something called a graph that is not</p>



<p class="wp-block-paragraph">connected. We&#8217;ll talk about all that terminology and how to detect it in a future video. For now,</p>



<p class="wp-block-paragraph">I&#8217;m just going to say we have like a little graph here, which is kind of boring, but I&#8217;m going to</p>



<p class="wp-block-paragraph">add an edge. An edge is basically just, you know, a little mini data structure that connects two</p>



<p class="wp-block-paragraph">nodes. Depending on the way you represent this in the machine, which we&#8217;ll talk about in future</p>



<p class="wp-block-paragraph">well, a whole bunch of different ways.</p>



<p class="wp-block-paragraph">You could imagine this as a full-fledged class,</p>



<p class="wp-block-paragraph">although that&#8217;s not always going to be the way that we represent an actual edge.</p>



<p class="wp-block-paragraph">So imagine that we have a nested class called edge.</p>



<p class="wp-block-paragraph">And inside the edge class, we&#8217;ve got, you know, some stuff.</p>



<p class="wp-block-paragraph">We could have a weight, which means the cost of traveling against the edge.</p>



<p class="wp-block-paragraph">We could have many other properties.</p>



<p class="wp-block-paragraph">For now, I&#8217;ll just try to keep it simple.</p>



<p class="wp-block-paragraph">is pretty much a collection of vertices and edges and some sort of connection.</p>



<p class="wp-block-paragraph">What is a graph really for?</p>



<p class="wp-block-paragraph">Some people at first think that a graph is another way to represent a database.</p>



<p class="wp-block-paragraph">I&#8217;m going to erase this thing over here.</p>



<p class="wp-block-paragraph">Graphs, you could sort of use them as databases,</p>



<p class="wp-block-paragraph">but they&#8217;re not very good as databases because</p>



<p class="wp-block-paragraph">it would be really, really slow to search through the graph</p>



<p class="wp-block-paragraph">to find some piece of data that you&#8217;re looking for.</p>



<p class="wp-block-paragraph">It could be like a linear time database.</p>



<p class="wp-block-paragraph">better would be to take this graph and add a bunch of rules as you probably have found</p>



<p class="wp-block-paragraph">in my other videos by now and turn it into a binary search tree.</p>



<p class="wp-block-paragraph">A binary search tree is lightning fast.</p>



<p class="wp-block-paragraph">It runs in log time.</p>



<p class="wp-block-paragraph">Hash tables are faster than binary search trees, but basically a graph is always going</p>



<p class="wp-block-paragraph">to be way slower than a binary search tree unless the binary search tree is severely</p>



<p class="wp-block-paragraph">imbalanced.</p>



<p class="wp-block-paragraph">But that&#8217;s something for another video.</p>



<p class="wp-block-paragraph">Anyway, so we have a graph and it&#8217;s not a good database.</p>



<p class="wp-block-paragraph">What would a graph be good for?</p>



<p class="wp-block-paragraph">would a graph be good for? Well, graphs are usually pretty good to help you represent</p>



<p class="wp-block-paragraph">relationships between things. For example, the six and the one, imagine the six is something,</p>



<p class="wp-block-paragraph">maybe it&#8217;s a computer, maybe it&#8217;s a city, maybe it&#8217;s, I don&#8217;t know, like a train station,</p>



<p class="wp-block-paragraph">and the edges could represent connections. So I&#8217;m just going to start changing these values</p>



<p class="wp-block-paragraph">have some nodes just kind of hanging out off to the side, not really connected to anything.</p>



<p class="wp-block-paragraph">Maybe not great for your particular use case, but like it&#8217;s a valid graph. So I&#8217;m just going to,</p>



<p class="wp-block-paragraph">I&#8217;m just going to connect this and try to make this into a better graph.</p>



<p class="wp-block-paragraph">That&#8217;s a little bit more interesting. So we&#8217;ve got graphs that do a whole bunch of different</p>



<p class="wp-block-paragraph">things. Let me change these values real fast. I&#8217;ll maybe turn that into a 13 and turn that</p>



<p class="wp-block-paragraph">So imagine that we have like a little connection here, a little connection here, maybe another</p>



<p class="wp-block-paragraph">connection here and another one there.</p>



<p class="wp-block-paragraph">And you know, you are allowed to have connections that sort of look weird, like going from this</p>



<p class="wp-block-paragraph">six all the way around to this 13.</p>



<p class="wp-block-paragraph">That&#8217;s totally valid also.</p>



<p class="wp-block-paragraph">So I&#8217;ve basically just drawn a random graph, random nodes and random edges.</p>



<p class="wp-block-paragraph">Imagine that every single node here is a computer in a computer network and imagine every edge</p>



<p class="wp-block-paragraph">every edge which connects the nodes is just some sort of a connection let&#8217;s say a network cable</p>



<p class="wp-block-paragraph">or a wi-fi signal or something like that so if you imagine it that way then this graph could</p>



<p class="wp-block-paragraph">represent a network topology a bunch of computers connected together if these were cities and this</p>



<p class="wp-block-paragraph">is like actually maybe these are airports in cities you could imagine a graph could represent</p>



<p class="wp-block-paragraph">the relationship between different airports in which planes will fly notice on this graph just</p>



<p class="wp-block-paragraph">that the uh you know the uh the city number one uh there are no flights connecting it directly to</p>



<p class="wp-block-paragraph">city 44 but you could probably imagine well if we take a flight to uh from city one to city 10 and</p>



<p class="wp-block-paragraph">then from city 10 to 44 then we can get from one to 44 we just have to be clever about our connecting</p>



<p class="wp-block-paragraph">flights um let&#8217;s see so we could do like road maps airport maps the worldwide web is basically a graph</p>



<p class="wp-block-paragraph">at least from a certain perspective electrical circuits that are connected to each other</p>



<p class="wp-block-paragraph">are connected to each other even game maps what if your character is allowed to stand here in</p>



<p class="wp-block-paragraph">in space number three on some map and the character is only allowed to travel to space 13 or</p>



<p class="wp-block-paragraph">space 6 but not directly to space 1 well it could be a map that helps you understand where your</p>



<p class="wp-block-paragraph">character can go in a game okay so that&#8217;s like the basic idea of of what a graph is and uh how it</p>



<p class="wp-block-paragraph">actual four types of graphs that I&#8217;m going to go over in more detail in future videos. Let&#8217;s see,</p>



<p class="wp-block-paragraph">what time is it right now? We got like 10 minutes. Okay, so I can still kind of make this fast.</p>



<p class="wp-block-paragraph">So the first type of graph that we&#8217;re looking at right now is actually something called an</p>



<p class="wp-block-paragraph">undirected, unweighted graph. Why is it, let&#8217;s see, let me write this down first. It&#8217;s an undirected,</p>



<p class="wp-block-paragraph">undirected, unweighted graph. So why is this undirected? Because the edges don&#8217;t have direction.</p>



<p class="wp-block-paragraph">If I was standing in, you know, city six and I wanted to like drive or fly or whatever</p>



<p class="wp-block-paragraph">from city six to city three, then I should be able to do it because this edge that connects</p>



<p class="wp-block-paragraph">them doesn&#8217;t really say that I have to go in one direction or the other. I could also go to city</p>



<p class="wp-block-paragraph">three and then just walk right back or fly right back to city six. There&#8217;s no direction. So there&#8217;s</p>



<p class="wp-block-paragraph">no direction. So there&#8217;s an this that&#8217;s that&#8217;s why this is an undirected graph. This is an</p>



<p class="wp-block-paragraph">unweighted graph because we haven&#8217;t specified a cost for traveling along an edge. For example,</p>



<p class="wp-block-paragraph">if you know, if you&#8217;re at city three here, and you want to fly to city 13, how much jet fuel</p>



<p class="wp-block-paragraph">does it cost? How much time does it cost? If three is a computer and 13 is a computer,</p>



<p class="wp-block-paragraph">and the edges like a network cable, like how much money does it cost to transmit the data?</p>



<p class="wp-block-paragraph">transmit the data or what is the lag in milliseconds.</p>



<p class="wp-block-paragraph">You know, you can represent all sorts of things with these edges,</p>



<p class="wp-block-paragraph">but there&#8217;s no value on these edges,</p>



<p class="wp-block-paragraph">which means there are no weights to these edges.</p>



<p class="wp-block-paragraph">So that&#8217;s why this is an undirected and also unweighted graph.</p>



<p class="wp-block-paragraph">Uh, the first upgrade that I want to do is just kind of show you what you can</p>



<p class="wp-block-paragraph">sort of assume about an unweighted graph. This is not always true.</p>



<p class="wp-block-paragraph">It just depends on who you talk to and what your application implementations are.</p>



<p class="wp-block-paragraph">So imagine the node that goes from six, sorry, the edge that goes from six to one.</p>



<p class="wp-block-paragraph">If it&#8217;s an unweighted graph, you could just probably imagine that every weight is just a one.</p>



<p class="wp-block-paragraph">The point being that it always costs the same amount to travel along every edge,</p>



<p class="wp-block-paragraph">because in an unweighted graph, we don&#8217;t differentiate between the different edges</p>



<p class="wp-block-paragraph">in terms of their costs.</p>



<p class="wp-block-paragraph">We could just put a bunch of ones on all these edges.</p>



<p class="wp-block-paragraph">And it would still, you know, basically be considered an unweighted graph.</p>



<p class="wp-block-paragraph">It depends on who you talk to.</p>



<p class="wp-block-paragraph">maybe all the weights are zero, maybe all the weights are 10 or whatever.</p>



<p class="wp-block-paragraph">But, you know, usually I put a one there because I&#8217;d like to imagine the cost could just be the number of hops.</p>



<p class="wp-block-paragraph">So, for example, if I wanted to go from city six to city 10,</p>



<p class="wp-block-paragraph">I could probably, you know, start at city six and then go to city one and then hop to city 10.</p>



<p class="wp-block-paragraph">How many actual hops did I do? I did two.</p>



<p class="wp-block-paragraph">I could also come up with that number by just looking at the sum of all the weights of all the edges.</p>



<p class="wp-block-paragraph">all the edges. So notice how when I go from six to one, that costs me one weight or one hop. And</p>



<p class="wp-block-paragraph">then when I go from one to 10, that&#8217;s another one. So if you put ones on all the edges in an</p>



<p class="wp-block-paragraph">unweighted graph, then you&#8217;re kind of saying the total cost of some path is really just the number</p>



<p class="wp-block-paragraph">of hops. So it&#8217;s up to you. Anyway, that&#8217;s unweighted and undirected. Let&#8217;s upgrade this</p>



<p class="wp-block-paragraph">see we have an undirected and unweighted and i&#8217;m just going to duplicate this real fast and change</p>



<p class="wp-block-paragraph">this to a weighted graph so undirected but also weighted and the thing is as soon as you start</p>



<p class="wp-block-paragraph">putting numbers on a graph on the edges of a graph well then it&#8217;s considered weighted so even even a</p>



<p class="wp-block-paragraph">graph that has all ones on all the edges you could also call that weighted but now you have the</p>



<p class="wp-block-paragraph">freedom since it is considered a weighted graph to just assign different values to all the edges</p>



<p class="wp-block-paragraph">to all the edges. Again, these edges are a class sometimes, or you can think of them that way</p>



<p class="wp-block-paragraph">inside the graph. And the edge weights themselves are definitely considered a T type, a templated</p>



<p class="wp-block-paragraph">type, which means, you know, right now I&#8217;m clearly typing integers, but you could type some other</p>



<p class="wp-block-paragraph">data type. You could type floats. You could type some weird data type, like a string.</p>



<p class="wp-block-paragraph">Whether or not that&#8217;s going to be useful depends on your program, you know, what you&#8217;re trying to</p>



<p class="wp-block-paragraph">you know, what you&#8217;re trying to do with the graph. But let&#8217;s see, I think I&#8217;ve added custom numbers</p>



<p class="wp-block-paragraph">to every single edge. So now this is definitely an undirected, but weighted graph. That&#8217;s the</p>



<p class="wp-block-paragraph">second type of graph that we&#8217;re talking about. Okay, what&#8217;s what&#8217;s cool about a weighted graph?</p>



<p class="wp-block-paragraph">Well, imagine again, that this is an airport map, where we&#8217;re representing relationships between,</p>



<p class="wp-block-paragraph">you know, cities, like where can we fly and stuff. We&#8217;re basically saying at this point,</p>



<p class="wp-block-paragraph">it&#8217;s going to cost you 44 of something.</p>



<p class="wp-block-paragraph">Maybe this is a graph representing jet fuel or time or frequent flyer points or something like that.</p>



<p class="wp-block-paragraph">If you consider your edges to be custom classes,</p>



<p class="wp-block-paragraph">you could even put a whole bunch of different types of values in your graph at the same time</p>



<p class="wp-block-paragraph">to make it a little bit more flexible.</p>



<p class="wp-block-paragraph">But for now, we&#8217;ll just say there&#8217;s one templated type,</p>



<p class="wp-block-paragraph">which means if we go back up to this code real fast, where was that code at?</p>



<p class="wp-block-paragraph">Where was that code at?</p>



<p class="wp-block-paragraph">And we had, you know, our rough idea of, you know, what the, what the graph holds, you</p>



<p class="wp-block-paragraph">know, it holds like vertices and edges.</p>



<p class="wp-block-paragraph">We could upgrade this just a little bit to say that there is a, an edge value type.</p>



<p class="wp-block-paragraph">So I&#8217;m going to say class edge value, edge weight type, something like that.</p>



<p class="wp-block-paragraph">for the edge so that I can save characters. And then here, I&#8217;ll change this to a type for the</p>



<p class="wp-block-paragraph">node. This is why we call it T type. There&#8217;s like, we put the keyword template here in C++.</p>



<p class="wp-block-paragraph">And then sometimes people just use T&#8217;s here for these tokens. So I&#8217;m just going to say</p>



<p class="wp-block-paragraph">the type of data that a node can hold is going to be the T node. And then the type of data that</p>



<p class="wp-block-paragraph">the edge could hold would be the T edge. We&#8217;ll call that data. Or we could call that weight,</p>



<p class="wp-block-paragraph">because usually that data comes into play when you&#8217;re traveling along an edge, right? So there&#8217;s</p>



<p class="wp-block-paragraph">traveling along an edge, right? So there&#8217;s like two different types here. Anyway, so we got an</p>



<p class="wp-block-paragraph">undirected and unweighted graph. If we traveled from city six to city one, that costs us 44. But</p>



<p class="wp-block-paragraph">if you look at the graph a little bit more closely, we could take the longer way around. We could say</p>



<p class="wp-block-paragraph">go from six to three, and then go from three to 13. And then actually, let me change the color</p>



<p class="wp-block-paragraph">to orange so that you can see there&#8217;s different paths, six to three, and then three to 13,</p>



<p class="wp-block-paragraph">and then 13 to one, even though we took more hops,</p>



<p class="wp-block-paragraph">and that might have been considered more expensive</p>



<p class="wp-block-paragraph">in an unweighted graph,</p>



<p class="wp-block-paragraph">you can see that the cost of the first path</p>



<p class="wp-block-paragraph">from six to one, that&#8217;s 44.</p>



<p class="wp-block-paragraph">And the cost of the second path is seven plus three,</p>



<p class="wp-block-paragraph">that&#8217;s 10, and then plus nine, so that&#8217;s 19.</p>



<p class="wp-block-paragraph">So if we take the long way,</p>



<p class="wp-block-paragraph">it actually costs us less</p>



<p class="wp-block-paragraph">of whatever we&#8217;ve determined this unit is.</p>



<p class="wp-block-paragraph">You know, less jet fuel, less time, less whatever.</p>



<p class="wp-block-paragraph">less whatever these graphs in the machine are not necessarily going to be to scale because the</p>



<p class="wp-block-paragraph">machine in your computer your computer doesn&#8217;t really keep track of like the physical positioning</p>



<p class="wp-block-paragraph">of all these nodes and edges it just can keeps track of the relationship between the nodes and</p>



<p class="wp-block-paragraph">the edges and the weights and all that stuff so two different paths that we could take to get</p>



<p class="wp-block-paragraph">from six to one one of the paths is less expensive um or less time costly or just whatever and a graph</p>



<p class="wp-block-paragraph">data structure can kind of help us figure that out if we&#8217;re using an algorithm that understands</p>



<p class="wp-block-paragraph">weights okay so undirected and unweighted let&#8217;s add direction so um i&#8217;m going to erase this stuff</p>



<p class="wp-block-paragraph">right here real quick and in an undirected graph remember you can just kind of go in either</p>



<p class="wp-block-paragraph">direction along any edge but in a directed graph every single edge needs to have a direction so as</p>



<p class="wp-block-paragraph">I change one of the edges to have direction, then I must change all of the edges to have direction</p>



<p class="wp-block-paragraph">as well. So I&#8217;m just saying, okay, as soon as I did that, now this is an invalid graph</p>



<p class="wp-block-paragraph">because some of the edges don&#8217;t have direction. So now I need to fix everything. So I just,</p>



<p class="wp-block-paragraph">I&#8217;m going to arbitrarily and randomly choose a direction for every single edge like this.</p>



<p class="wp-block-paragraph">And then as soon as I&#8217;m done, I&#8217;m going to deal, I guess, with that giant edge</p>



<p class="wp-block-paragraph">that giant edge. So I&#8217;m going to go like that. So let&#8217;s see, all the edges seem to have direction.</p>



<p class="wp-block-paragraph">Now I&#8217;m just going to hand draw an arrow on one side of this giant edge. Okay. So this is directed</p>



<p class="wp-block-paragraph">and also weighted. What can we do with the directed graph? Well, it just basically tells</p>



<p class="wp-block-paragraph">you which direction you&#8217;re allowed to travel in. What if you have an airport where city six can</p>



<p class="wp-block-paragraph">only fly to city one, but city one, for some reason, never flies to city six. You got to take</p>



<p class="wp-block-paragraph">take like the long way you got to go from city one to 13 to three to six that&#8217;s something that</p>



<p class="wp-block-paragraph">a graph could help you represent what if your character in your game can only go in one direction</p>



<p class="wp-block-paragraph">but not the other direction okay no problem i mean that&#8217;s pretty much it you&#8217;re only allowed</p>



<p class="wp-block-paragraph">to travel in the same direction as the edge points but now we have a graph that is a lot less</p>



<p class="wp-block-paragraph">flexible because for example before we used to be able to go from city uh 10 to city 44 and then</p>



<p class="wp-block-paragraph">then come back again later if we wanted in the opposite direction. We can no longer do that</p>



<p class="wp-block-paragraph">because this edge only goes to 10. It doesn&#8217;t even go to 44. We can&#8217;t even ever actually get to 44.</p>



<p class="wp-block-paragraph">How do you sort of solve that? Well, just add another edge in the opposite direction.</p>



<p class="wp-block-paragraph">In graphs, you are allowed to do something called a parallel edge,</p>



<p class="wp-block-paragraph">which just basically means, you know, two edges between the same pair of nodes that just point</p>



<p class="wp-block-paragraph">in the same direction. You&#8217;re also allowed to do, you know, opposite facing edges. So</p>



<p class="wp-block-paragraph">edges so i just added a second edge there going from 10 to 44 and now if i was you know hanging</p>



<p class="wp-block-paragraph">out in city 10 i could just go back and forth between city 10 and 44 as much as i wanted to</p>



<p class="wp-block-paragraph">oh i forgot to add an edge weight for that new edge which means i wrote down an invalid graph</p>



<p class="wp-block-paragraph">so i&#8217;m just going to say two so uh maybe the wind is blowing in in your favor when you&#8217;re going from</p>



<p class="wp-block-paragraph">city 10 to city 44 maybe it&#8217;s blowing against you if you&#8217;re talking about city 44 to city 10 you</p>



<p class="wp-block-paragraph">you know whatever but you just have to have edge uh edge weight on every single edge</p>



<p class="wp-block-paragraph">okay so uh that&#8217;s directed and also weighted um and you can probably imagine previously when we</p>



<p class="wp-block-paragraph">had an undirected um graph when there was just like you know one edge going between uh two nodes</p>



<p class="wp-block-paragraph">and there was no direction on it like you know 44 to 10 if we just had like one edge with no</p>



<p class="wp-block-paragraph">have two edges each going in the opposite direction so we have directed and weighted i think the last</p>



<p class="wp-block-paragraph">thing that we didn&#8217;t do was directed and unweighted right so we have let me just double check real</p>



<p class="wp-block-paragraph">fast here we have undirected and unweighted and then we had undirected and weighted and then</p>



<p class="wp-block-paragraph">directed and weighted okay so now let&#8217;s do um i&#8217;m getting lost already oh my gosh i can&#8217;t believe i</p>



<p class="wp-block-paragraph">I saw undirected and unweighted so we did undirected twice already undirected so we&#8217;re</p>



<p class="wp-block-paragraph">going to do directed and unweighted next okay so the next graph a little bit less useful than</p>



<p class="wp-block-paragraph">what we&#8217;re looking at this this type of graph is a little bit more useful we&#8217;re going to do</p>



<p class="wp-block-paragraph">directed and unweighted oh my god okay directed and unweighted so directed and unweighted you</p>



<p class="wp-block-paragraph">Directed and unweighted, you can imagine, just means we get rid of all these weights.</p>



<p class="wp-block-paragraph">And then we keep the direction on all the edges.</p>



<p class="wp-block-paragraph">So this means we can keep track of where we&#8217;re allowed to go, if we&#8217;re pathfinding or just whatever.</p>



<p class="wp-block-paragraph">But we don&#8217;t really know what it costs to travel between the different graphs.</p>



<p class="wp-block-paragraph">So that&#8217;s directed and unweighted.</p>



<p class="wp-block-paragraph">Let&#8217;s see here.</p>



<p class="wp-block-paragraph">I&#8217;m going to just duplicate this or just make a new blank slide.</p>



<p class="wp-block-paragraph">Okay, undirected, oh gosh, I&#8217;ve got pink letters.</p>



<p class="wp-block-paragraph">Let&#8217;s see, undirected plus unweighted.</p>



<p class="wp-block-paragraph">And we&#8217;ve got undirected plus weighted.</p>



<p class="wp-block-paragraph">And then we&#8217;ve got directed plus unweighted.</p>



<p class="wp-block-paragraph">I don&#8217;t think I&#8217;m writing these down in the same order,</p>



<p class="wp-block-paragraph">but that&#8217;s okay.</p>



<p class="wp-block-paragraph">And then we&#8217;ve got directed plus weighted.</p>



<p class="wp-block-paragraph">So basically, you know, four types of graphs</p>



<p class="wp-block-paragraph">that we can talk about.</p>



<p class="wp-block-paragraph">In future videos, we&#8217;re going to go over graphs</p>



<p class="wp-block-paragraph">in more detail.</p>



<p class="wp-block-paragraph">We&#8217;ll talk about graph terminology,</p>



<p class="wp-block-paragraph">maybe some pathfinding algorithms.</p>



<p class="wp-block-paragraph">And yeah, so this is just a basic intro.</p>



<p class="wp-block-paragraph">How much time do we spend already?</p>



<p class="wp-block-paragraph">Oh God, we spent so much time.</p>



<p class="wp-block-paragraph">Spent like 22 minutes.</p>



<p class="wp-block-paragraph">Dang, man, even the smallest thing takes time.</p>



<p class="wp-block-paragraph">So I&#8217;ll see you in a future video</p>



<p class="wp-block-paragraph">when we talk more and more and more about graphs</p>



<p class="wp-block-paragraph">and other data structures concepts.</p>



<p class="wp-block-paragraph">Thanks for watching this video.</p>



<p class="wp-block-paragraph">I hope you learned a little bit of stuff</p>



<p class="wp-block-paragraph">I hope you learned a little bit of stuff and had a little bit of fun.</p>



<p class="wp-block-paragraph">I&#8217;m out of here.</p>



<p class="wp-block-paragraph">Go.</p>



<p class="wp-block-paragraph">Hey, everybody.</p>



<p class="wp-block-paragraph">Thanks for watching this video again from the bottom of my heart.</p>



<p class="wp-block-paragraph">I really appreciate it.</p>



<p class="wp-block-paragraph">I do hope you did learn something and have some fun.</p>



<p class="wp-block-paragraph">If you could do me a please, a small little favor,</p>



<p class="wp-block-paragraph">could you please subscribe and follow this channel or these videos</p>



<p class="wp-block-paragraph">or whatever it is you do on the current social media website that you&#8217;re looking at right now,</p>



<p class="wp-block-paragraph">it would really mean the world to me.</p>



<p class="wp-block-paragraph">And it&#8217;ll help make more videos and grow this community.</p>



<p class="wp-block-paragraph">So we&#8217;ll be able to do more videos, longer videos, better videos,</p>



<p class="wp-block-paragraph">or just I&#8217;ll be able to keep making videos in general.</p>



<p class="wp-block-paragraph">So please do me a kindness and subscribe.</p>



<p class="wp-block-paragraph">You know, sometimes I&#8217;m sleeping in the middle of the night</p>



<p class="wp-block-paragraph">and I just wake up because I know somebody subscribed or followed.</p>



<p class="wp-block-paragraph">It just wakes me up and I get filled with joy.</p>



<p class="wp-block-paragraph">That&#8217;s exactly what happens every single time.</p>



<p class="wp-block-paragraph">So you could do it as a nice favor to me or you could you control me if you want to just wake me up in the middle</p>



<p class="wp-block-paragraph">And I just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen</p>



<p class="wp-block-paragraph">Also, if you look at the middle of the screen right now</p>



<p class="wp-block-paragraph">You should see a QR code which you can scan in order to go to the website</p>



<p class="wp-block-paragraph">which I think is also named somewhere at the bottom of this video and</p>



<p class="wp-block-paragraph">It&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p class="wp-block-paragraph">I published and the services and tutorials and things that I offer and all that good stuff and</p>



<p class="wp-block-paragraph">and if you have a suggestion for clarifications or errata or just future</p>



<p class="wp-block-paragraph">videos that you want to see please leave a comment or if you just want to say hey</p>



<p class="wp-block-paragraph">what&#8217;s up what&#8217;s going on you know just send me a comment whatever I also wake</p>



<p class="wp-block-paragraph">up for those in the middle of the night I get I wake up in a cold sweat I&#8217;m like</p>



<p class="wp-block-paragraph">it would really it really mean the world to me I would really appreciate it so</p>



<p class="wp-block-paragraph">enjoy the cool music as as I fade into the darkness which is coming for us all.</p>



<p class="wp-block-paragraph">Thank you.</p>



<p class="wp-block-paragraph">I&#8217;m going to go ahead and get started.</p>



<p class="wp-block-paragraph">Thank you.</p>



<p class="wp-block-paragraph">Hello there.</p>



<p class="wp-block-paragraph">Let&#8217;s talk about the four types of…</p>



<p class="wp-block-paragraph">Hello there.</p>
<p>The post <a href="https://www.NeuralLantern.com/4-graph-types-undirected-vs-directed-weighted-vs-unweighted/">4 Graph Types: Undirected vs Directed, Weighted vs Unweighted</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/4-graph-types-undirected-vs-directed-weighted-vs-unweighted/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
