<?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>adjacency matrix tutorial Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/adjacency-matrix-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/adjacency-matrix-tutorial/</link>
	<description></description>
	<lastBuildDate>Mon, 12 Oct 2026 06:55:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>adjacency matrix tutorial Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/adjacency-matrix-tutorial/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Represent an Undirected Unweighted Graph with an Adjacency Matrix</title>
		<link>https://www.NeuralLantern.com/how-to-represent-an-undirected-unweighted-graph-with-an-adjacency-matrix/</link>
					<comments>https://www.NeuralLantern.com/how-to-represent-an-undirected-unweighted-graph-with-an-adjacency-matrix/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 12 Oct 2026 06:55:15 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Graphs]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[adjacency matrix]]></category>
		<category><![CDATA[adjacency matrix tutorial]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[coding interview]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[edge list vs adjacency matrix]]></category>
		<category><![CDATA[graph algorithms]]></category>
		<category><![CDATA[graph data structure]]></category>
		<category><![CDATA[graph representation]]></category>
		<category><![CDATA[graph theory]]></category>
		<category><![CDATA[matrix graph]]></category>
		<category><![CDATA[self loop graph]]></category>
		<category><![CDATA[undirected graph]]></category>
		<category><![CDATA[unweighted graph]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=437</guid>

					<description><![CDATA[<p>Represent an undirected unweighted graph as an adjacency matrix of ones and zeros. A one in the cell at row i and column j means an edge exists between those nodes. Because the graph is undirected the matrix is symmetric across the diagonal. Changing a cell from zero to one adds an edge and changing it back removes the edge. Self-loops appear on the diagonal. This representation stores only the connection relationships and supports constant-time edge checks.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-represent-an-undirected-unweighted-graph-with-an-adjacency-matrix/">How to Represent an Undirected Unweighted Graph with an Adjacency Matrix</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 Undirected Unweighted Graph with an Adjacency Matrix" width="1380" height="776" src="https://www.youtube.com/embed/tzCqcHK-9Tw?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 store an undirected unweighted graph inside a computer using an adjacency matrix. In this video we build a matrix of ones and zeros where each cell shows whether an edge exists between two nodes. Rows represent the starting node and columns represent the ending node. Because the graph is undirected the matrix ends up as a mirror image across the diagonal. We also cover how to add or remove edges by simply changing a cell value, how self-loops appear on the diagonal, and why this representation lets you check any connection in constant time. The computer only needs the connection data, not the physical layout of the nodes. Perfect if you are learning graph theory, data structures, or preparing for algorithm interviews.</p>



<p class="wp-block-paragraph">0:00 Introduction to Adjacency Matrix<br>1:16 Arrays as Two Dimensional Matrices<br>2:20 Ones and Zeros Represent Edges<br>3:44 Filling the Matrix for Node One<br>6:20 Completing the Remaining Nodes<br>10:38 Finished Matrix and Practice Advice<br>11:02 Computer Stores Only Connections<br>11:40 Mirror Property of Undirected Graphs<br>14:17 Adding and Removing Edges<br>17:31 Parallel Edges Are Not Supported<br>18:50 Conclusion and Future Topics</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><a href="https://www.NeuralLantern.com/social">https://www.NeuralLantern.com/social</a></li>



<li>Twitter / X: <a href="https://x.com/NeuralLantern">https://x.com/NeuralLantern</a></li>



<li>Rumble: <a href="https://rumble.com/c/c-3696939">https://rumble.com/c/c-3696939</a></li>



<li>BitChute: <a href="https://www.bitchute.com/channel/pg1Pvv5dN4Gt">https://www.bitchute.com/channel/pg1Pvv5dN4Gt</a></li>



<li>Daily Motion: <a href="https://www.dailymotion.com/neurallantern">https://www.dailymotion.com/neurallantern</a></li>



<li>Minds: <a href="https://www.minds.com/neurallantern/">https://www.minds.com/neurallantern/</a></li>



<li>Odysee: <a href="https://odysee.com/@NeuralLantern:5">https://odysee.com/@NeuralLantern:5</a></li>
</ul>



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



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



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



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



<li>Subscribe to the Blog: <a href="https://www.NeuralLantern.com">https://www.NeuralLantern.com</a></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 representing an undirected,</p>



<p class="wp-block-paragraph">unweighted graph in your machine using an adjacency matrix.</p>



<p class="wp-block-paragraph">All right everybody, so I hope you&#8217;ve been watching my previous videos.</p>



<p class="wp-block-paragraph">I just did some videos on edge list representation. Before that,</p>



<p class="wp-block-paragraph">I talked about like the basics of graphs and like terminology and stuff like that.</p>



<p class="wp-block-paragraph">You don&#8217;t need</p>



<p class="wp-block-paragraph">terminology and stuff like that. You don&#8217;t need to watch the edge list videos if you&#8217;re not</p>



<p class="wp-block-paragraph">interested in representing using an edge list, but you should probably at least watch the graphing</p>



<p class="wp-block-paragraph">video basics if you haven&#8217;t. Okay, so what are we looking at right here? I&#8217;ve just made a graph.</p>



<p class="wp-block-paragraph">I made a random graph and I kind of like, you know, wired up a bunch of edges to make it kind</p>



<p class="wp-block-paragraph">of complicated. I then spent a whole bunch of time making this very beautiful two-dimensional</p>



<p class="wp-block-paragraph">Matrix, just for you. I&#8217;m sorry you couldn&#8217;t watch me</p>



<p class="wp-block-paragraph">you i&#8217;m sorry you couldn&#8217;t watch me write it you know i sometimes i&#8217;ll i&#8217;ll have people say that</p>



<p class="wp-block-paragraph">they like when i yell at myself while i&#8217;m drawing something sorry it took too long but anyway what</p>



<p class="wp-block-paragraph">we&#8217;re going to do is take these concepts and put them together and we&#8217;ll we&#8217;ll say this is how we</p>



<p class="wp-block-paragraph">can represent the graph inside of the machine so what am i even talking about uh well the first</p>



<p class="wp-block-paragraph">thing is imagine an array in your machine right an array of integers like an array of uh i don&#8217;t know</p>



<p class="wp-block-paragraph">doubles you know an array of whatever so i&#8217;m gonna say like 5.4 and like you know 7.7 and</p>



<p class="wp-block-paragraph">8 and you know like whatever so i&#8217;m just like making an array of numbers probably a lot of</p>



<p class="wp-block-paragraph">you like this notation but inside your machine an array uh that is one-dimensional could be</p>



<p class="wp-block-paragraph">interpreted as a two-dimensional array so this matrix up here on the top right of the screen</p>



<p class="wp-block-paragraph">that&#8217;s really a one-dimensional ray array inside of the computer it&#8217;s just that we choose to treat</p>



<p class="wp-block-paragraph">it as a two-dimensional array.</p>



<p class="wp-block-paragraph">a two-dimensional array and um it&#8217;s important to understand that you can jump to any cell</p>



<p class="wp-block-paragraph">in constant time uh just like you can with a one-dimensional array because getting to a certain</p>



<p class="wp-block-paragraph">cell is really just a simple mathematical formula i think i&#8217;m going to do time complexities of this</p>



<p class="wp-block-paragraph">in a different video so for now i&#8217;m just going to say here&#8217;s how we represent the diagram first off</p>



<p class="wp-block-paragraph">let me label this so i don&#8217;t forget uh this is definitely where the heck is that how come that&#8217;s</p>



<p class="wp-block-paragraph">That&#8217;s not working, okay.</p>



<p class="wp-block-paragraph">Oh, this is definitely.</p>



<p class="wp-block-paragraph">okay uh this is definitely an undirected unweighted graph</p>



<p class="wp-block-paragraph">trying to type with the pen in my hand i have to change my brain okay</p>



<p class="wp-block-paragraph">so this is an undirected and also unweighted graph</p>



<p class="wp-block-paragraph">so for the purposes of this particular graph if it&#8217;s unweighted that means in the cells um we&#8217;re</p>



<p class="wp-block-paragraph">just we&#8217;re not going to put weight because there&#8217;s no weight in the graph i mean you could if you</p>



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



<p class="wp-block-paragraph">the graph i mean you could if you wanted to just say that every edge was a weight of one if it was</p>



<p class="wp-block-paragraph">unweighted but i&#8217;m gonna say let&#8217;s forget about you know what is the actual value of an edge</p>



<p class="wp-block-paragraph">because we don&#8217;t really have that in this graph and we&#8217;ll just say that if an edge exists then uh</p>



<p class="wp-block-paragraph">we&#8217;ll put a we&#8217;ll put a one there and if an edge does not exist we&#8217;ll put a zero in there</p>



<p class="wp-block-paragraph">at the corresponding cell we&#8217;ll talk about what cells mean you know what edges in a second</p>



<p class="wp-block-paragraph">The other thing is because it&#8217;s undirected, it doesn&#8217;t actually matter.</p>



<p class="wp-block-paragraph">It doesn&#8217;t actually matter whether we&#8217;re describing a start node or an end node with an edge because it goes in both directions.</p>



<p class="wp-block-paragraph">So actually what&#8217;s going to happen is this graph is going to be a mirror.</p>



<p class="wp-block-paragraph">I&#8217;ll show it to you in a second, but for now we&#8217;ll just say it&#8217;s not going to matter what the direction is.</p>



<p class="wp-block-paragraph">I like to do starting nodes as the rows, even though I just said that doesn&#8217;t matter.</p>



<p class="wp-block-paragraph">It&#8217;s just the way that I like to do things because it makes it easier to remember how to do this when you start to add direction to the graph.</p>



<p class="wp-block-paragraph">the graph so one by one i&#8217;m going to look at every single node and i&#8217;m going to chart what exactly is</p>



<p class="wp-block-paragraph">going on with that node in the two-dimensional matrix so i&#8217;m going to start uh i guess i&#8217;m going</p>



<p class="wp-block-paragraph">to go numerically because that&#8217;s kind of easier i&#8217;m going to start with the node index 1. so i&#8217;m</p>



<p class="wp-block-paragraph">going to go here at row 1 because i&#8217;m going to say that&#8217;s my start node and um where does the</p>



<p class="wp-block-paragraph">one node connect to it connects to node number two so um let&#8217;s see actually i think i&#8217;m going</p>



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



<p class="wp-block-paragraph">actually, I think I&#8217;m going to say that it is not self-connected. I mean, if you consider your</p>



<p class="wp-block-paragraph">graph to have by default every node is connected to itself, you could put a one there across that</p>



<p class="wp-block-paragraph">little diagonal line that you see. But I&#8217;m going to put a zero saying that these nodes are not</p>



<p class="wp-block-paragraph">connected to themselves, unless we do a little loop from a node to itself. Maybe I should add</p>



<p class="wp-block-paragraph">that later. So node number one is connected to node number two. I&#8217;m going to write a one there</p>



<p class="wp-block-paragraph">to say that there is a connection.</p>



<p class="wp-block-paragraph">What do I mean by that?</p>



<p class="wp-block-paragraph">What do I mean by that? Just to clarify, this, let&#8217;s see, the one two edge, that edge that I</p>



<p class="wp-block-paragraph">just highlighted in pink, that corresponds to this cell. So the start node, I&#8217;m going to do</p>



<p class="wp-block-paragraph">that in maybe orange. The start node is the row number. And maybe I&#8217;ll do like, I don&#8217;t know,</p>



<p class="wp-block-paragraph">light blue or something, baby blue for the destination node. And that&#8217;s going to be the</p>



<p class="wp-block-paragraph">column number. So basically just like the row</p>



<p class="wp-block-paragraph">so basically just like the row number is where the node where you start what node you start at</p>



<p class="wp-block-paragraph">the column is what node you end at um and then if you see a zero or a one in that particular cell</p>



<p class="wp-block-paragraph">at that particular row and column it&#8217;ll tell you whether there&#8217;s an edge there or not</p>



<p class="wp-block-paragraph">so i&#8217;m going to duplicate this real fast so i can erase the markings i just made</p>



<p class="wp-block-paragraph">and i&#8217;m going to say oops whoa whoa what&#8217;s happening here i want to get dude</p>



<p class="wp-block-paragraph">dude are you kidding me can i just erase it like that yeah okay i keep thinking these are lines i</p>



<p class="wp-block-paragraph">actually made a diagram in a different program so these are not even lines i can&#8217;t even erase this</p>



<p class="wp-block-paragraph">it sucks so um we did the uh the two node so i&#8217;m just going to quickly say the one is connected</p>



<p class="wp-block-paragraph">also to the three yes or no yes that&#8217;s a one uh then the one node is connected to the four</p>



<p class="wp-block-paragraph">uh yes i&#8217;m going to put a one the one node is connected to the</p>



<p class="wp-block-paragraph">the one node is connected to the five yes so i&#8217;m going to put a one a lot of connections this is</p>



<p class="wp-block-paragraph">pretty good uh and then also to the six and not to the seven so if it&#8217;s not connected to the seven</p>



<p class="wp-block-paragraph">i&#8217;m going to put a zero there okay we do the same thing for the two node so i&#8217;m going to start at</p>



<p class="wp-block-paragraph">the two node actually let me duplicate this start at the two node and i&#8217;m going to say</p>



<p class="wp-block-paragraph">we&#8217;re now looking at the two node oh my gosh</p>



<p class="wp-block-paragraph">okay I&#8217;m gonna put a question mark I guess we&#8217;re looking at the two node and</p>



<p class="wp-block-paragraph">well is the two node connected to the one node yes we just saw that was true</p>



<p class="wp-block-paragraph">is the two node connected to itself we said in this particular graph there are</p>



<p class="wp-block-paragraph">no self connections by default because I want to be able to draw them if that</p>



<p class="wp-block-paragraph">ends up being true is the two connected to the three I see a connection there I</p>



<p class="wp-block-paragraph">see an edge so I&#8217;m gonna put a one is it connected to the four I don&#8217;t see an</p>



<p class="wp-block-paragraph">edge, I&#8217;m going to put a zero.</p>



<p class="wp-block-paragraph">the four i don&#8217;t see an edge so i&#8217;m gonna put a zero to the five uh yes to the six uh yes and to</p>



<p class="wp-block-paragraph">the seven um whoops what did i just do uh the two is not connected to the six i was thinking of the</p>



<p class="wp-block-paragraph">one uh the two connected to the seven yes okay so we just basically do this over and over and</p>



<p class="wp-block-paragraph">over again until you have a giant matrix of ones and zeros which can very efficiently store um</p>



<p class="wp-block-paragraph">store um a graph i mean this is pretty much it this is all you have to do i want to do uh let&#8217;s</p>



<p class="wp-block-paragraph">see three is connected to i&#8217;m gonna say one one and a two and it&#8217;s not connected to itself by</p>



<p class="wp-block-paragraph">default put a zero it&#8217;s connected to the four nope it&#8217;s connected to the five</p>



<p class="wp-block-paragraph">oh gosh i gotta make that even connected to the five</p>



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



<p class="wp-block-paragraph">i&#8217;m losing my brain here uh yes and then uh three connected to the six right three connected to the</p>



<p class="wp-block-paragraph">seven uh no okay somebody leave me a comment uh if you have a corruption and then for the four</p>



<p class="wp-block-paragraph">um let&#8217;s see dude this is getting out of control for the four um</p>



<p class="wp-block-paragraph">yes i&#8217;m just going to look at the diagram pretty soon we&#8217;re going to start realizing something fun</p>



<p class="wp-block-paragraph">about an underachiever.</p>



<p class="wp-block-paragraph">realizing something fun about an undirected graph in that it is a mirror in this matrix</p>



<p class="wp-block-paragraph">so technically you only have to do like one half of the matrix in your code if you wanted to</p>



<p class="wp-block-paragraph">so i&#8217;m gonna say the one exists um one you know what i should have done i should have just filled</p>



<p class="wp-block-paragraph">this whole thing with zeros and then change the zeros to ones um okay so the four is connected</p>



<p class="wp-block-paragraph">to the two, yes or no? Nope. All the fours connected to the three? Nope. Fours connect&#8230;</p>



<p class="wp-block-paragraph">Nope, or it&#8217;s connected to the 4, we&#8217;re going to say no by default, or it&#8217;s connected to the 5, nope, it&#8217;s only connected to the two things, it&#8217;ll just be the 7 I guess, okay, so we&#8217;re going to put a nope there, and then a yep for the 7.</p>



<p class="wp-block-paragraph">Okay, then the 5 is connected to 1, 2, 3, 4, what if I just did a whole bunch of zeros, and then I overwrote only the ones, that would probably be a little bit faster.</p>



<p class="wp-block-paragraph">bit faster except for this first time i&#8217;m doing it okay and then i&#8217;ll just copy paste this</p>



<p class="wp-block-paragraph">tap it past okay i should have done this should i edit that out of the video i don&#8217;t know it&#8217;s fun</p>



<p class="wp-block-paragraph">to watch my mistakes so five to one yes five to two no five to three yes uh five to four</p>



<p class="wp-block-paragraph">we say no by default five to six yes five to seven yes okay i think that was a little bit</p>



<p class="wp-block-paragraph">faster let&#8217;s see how fast it is this time uh the six is connected to the five well let&#8217;s say it&#8217;s</p>



<p class="wp-block-paragraph">the one and then uh a one a three a five and a seven right six one three five and seven okay so</p>



<p class="wp-block-paragraph">going to be one, three, five, seven. That&#8217;s probably right. Again, leave me a comment.</p>



<p class="wp-block-paragraph">probably right again leave me a comment if i screwed something up i did not practice this</p>



<p class="wp-block-paragraph">i&#8217;m just kind of winging it the seven is connected to uh five six two four five six okay so i&#8217;m gonna</p>



<p class="wp-block-paragraph">do two four five six whoops that six didn&#8217;t happen let me just do it again okay all right</p>



<p class="wp-block-paragraph">so now we have it this is a uh an adjacency matrix that represents the graph that you see on the left</p>



<p class="wp-block-paragraph">Keep in mind that if you saw a matrix, I mean in general you should probably practice doing this both ways, like look at a graph and then you generate the matrix that corresponds to the graph you&#8217;re looking at, but also maybe you&#8217;re presented with a matrix and you would draw the graph that the matrix represents.</p>



<p class="wp-block-paragraph">Try to remember that your computer, in almost every program, it doesn&#8217;t really know where these nodes are unless it&#8217;s a drawing program or something.</p>



<p class="wp-block-paragraph">if we&#8217;re just talking about relationships which is what graphs are kind of good at um then your</p>



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



<p class="wp-block-paragraph">um then your computer doesn&#8217;t really care that the three is on the top it doesn&#8217;t really know that</p>



<p class="wp-block-paragraph">definitely not with this adjacency matrix representation uh the three in the computer&#8217;s</p>



<p class="wp-block-paragraph">mind could just be anywhere it doesn&#8217;t really even think of where the nodes are it&#8217;s just</p>



<p class="wp-block-paragraph">this node is connected to that node and that node is connected to that node and so forth</p>



<p class="wp-block-paragraph">we just position the nodes somewhere because we&#8217;re humans and it&#8217;s fun to look at diagrams</p>



<p class="wp-block-paragraph">but really this is all your computer knows just all these you know little connection numbers here</p>



<p class="wp-block-paragraph">So, let me duplicate this and I&#8217;ll show you something funny about an undirected graph real quick.</p>



<p class="wp-block-paragraph">Let&#8217;s see, how much time? 12? That&#8217;s not too bad.</p>



<p class="wp-block-paragraph">So, if I do, let&#8217;s see, I want to do a little highlighter here.</p>



<p class="wp-block-paragraph">I don&#8217;t get a chance to do that very often.</p>



<p class="wp-block-paragraph">I&#8217;m going to do a highlighter across this identity line, you know, the little diagonal.</p>



<p class="wp-block-paragraph">It&#8217;s all zeros for self-connects.</p>



<p class="wp-block-paragraph">Maybe I&#8217;ll change that in a second.</p>



<p class="wp-block-paragraph">I&#8217;ll make one of the nodes connect to itself.</p>



<p class="wp-block-paragraph">But notice how if I do this.</p>



<p class="wp-block-paragraph">notice how if i do this in green</p>



<p class="wp-block-paragraph">notice oh is the highlighter going to be green now keep screwing that up notice how we have</p>



<p class="wp-block-paragraph">a mirror happening along the identity line so we have like some some ones here right uh so we have</p>



<p class="wp-block-paragraph">like two three four five six in the one row if we look at the one column we&#8217;ll also see two three</p>



<p class="wp-block-paragraph">four five six it&#8217;s a mirror uh pick you know any other numbers you want let&#8217;s look at the uh the</p>



<p class="wp-block-paragraph">The three column.</p>



<p class="wp-block-paragraph">at the uh the three column the three column has a one there and then it&#8217;s got another one and a one</p>



<p class="wp-block-paragraph">down below at the five and the six so three is hitting two and five and six uh let me look at</p>



<p class="wp-block-paragraph">the diagram just to make sure i&#8217;m doing this right three is hitting uh two and five and six</p>



<p class="wp-block-paragraph">it should be hitting one also oh right i didn&#8217;t highlight that because it was already highlighted</p>



<p class="wp-block-paragraph">by that other thing okay so then let&#8217;s look at the three row and see if we see a mirror also so</p>



<p class="wp-block-paragraph">two and then the five and the six notice how it&#8217;s a mirror you just tilt your head uh and it really</p>



<p class="wp-block-paragraph">looks like a mirror and sometimes i like to make a joke when i&#8217;m explaining this to people uh you</p>



<p class="wp-block-paragraph">know if you just kind of like tilt your head a little bit it looks like some cheesy broccoli</p>



<p class="wp-block-paragraph">i&#8217;m personally not a fan of cheesy broccoli i mean i love cheese and if you put cheese on my</p>



<p class="wp-block-paragraph">broccoli i&#8217;m gonna be happy but it turns what&#8217;s what was healthy food into junk food it&#8217;s like</p>



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



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



<p class="wp-block-paragraph">be healthy i&#8217;m gonna have broccoli today good for me yay i&#8217;ve earned a double bacon cheeseburger</p>



<p class="wp-block-paragraph">later but then i put cheese all over the broccoli and suddenly it&#8217;s junk food again and it&#8217;s like i</p>



<p class="wp-block-paragraph">do get a little fiber and everything but it&#8217;s like not really being that healthy anymore so what</p>



<p class="wp-block-paragraph">should i do i should just get some more healthy food to make up for the junk food broccoli and</p>



<p class="wp-block-paragraph">then i&#8217;m gonna end up putting cheese on the other healthy food and then i just it&#8217;s like an endless</p>



<p class="wp-block-paragraph">cycle and i just keep eating and eating and eating pretty soon there&#8217;s no room for a cheeseburger</p>



<p class="wp-block-paragraph">pretty soon there&#8217;s no room for a cheeseburger i don&#8217;t know what to tell you anyway um so this</p>



<p class="wp-block-paragraph">is how you make an undirected unweighted graph uh with an adjacency matrix we&#8217;ll talk about time</p>



<p class="wp-block-paragraph">complexities and other stuff in the future um uh oh i should talk about how to modify edges okay</p>



<p class="wp-block-paragraph">so first off let me let me create a self loop real fast i&#8217;m going to create a self connect</p>



<p class="wp-block-paragraph">but let&#8217;s say that this four is actually connecting to itself uh with like a little</p>



<p class="wp-block-paragraph">self-loop. Okay. So, oh shoot.</p>



<p class="wp-block-paragraph">so oh shoot how can i get rid of all those is that going to work yes it&#8217;s going to work yes</p>



<p class="wp-block-paragraph">i should have duplicated this and drawn on the duplicate maybe i actually did that forgot about</p>



<p class="wp-block-paragraph">it already i don&#8217;t even know okay sometimes i have clever ideas and then i forget what i was</p>



<p class="wp-block-paragraph">doing then the ideas are just not that clever anymore yes okay what about that highlighter</p>



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



<p class="wp-block-paragraph">i seem to have screwed up the graph somehow</p>



<p class="wp-block-paragraph">nope okay forget it um we&#8217;ll just pretend that it&#8217;s fine so i added that four connection</p>



<p class="wp-block-paragraph">so how do i modify the adjacency matrix well the four uh row starting node with the four column</p>



<p class="wp-block-paragraph">ending node was a zero indicating no self-connection now that i do have a self-connection</p>



<p class="wp-block-paragraph">And I&#8217;ll just put a one there, four and.</p>



<p class="wp-block-paragraph">connection i&#8217;ll just put a one there four and four and that&#8217;s it pretty easy right let me duplicate</p>



<p class="wp-block-paragraph">this other one so i don&#8217;t have to erase that stuff a second time a second time and um what</p>



<p class="wp-block-paragraph">will we do if we wanted to uh well let me actually sorry everybody let me just do that four one more</p>



<p class="wp-block-paragraph">time so i think i just erased the wrong thing we&#8217;ll say four and four is a one now and so how</p>



<p class="wp-block-paragraph">can we say that some new edge has been added?</p>



<p class="wp-block-paragraph">some new edge has been added let&#8217;s add an edge between one and seven pretty easy we just go to</p>



<p class="wp-block-paragraph">the right spot in the adjacency matrix let me add a little orange line here adjacency matrix</p>



<p class="wp-block-paragraph">to connect number one and number seven that would be uh we could do row one and column seven</p>



<p class="wp-block-paragraph">so that&#8217;s going to be a one and then remember this graph is undirected so it has to be a mirror</p>



<p class="wp-block-paragraph">so that means uh row seven and column one also has to be a one so it&#8217;s still a mirror</p>



<p class="wp-block-paragraph">so it&#8217;s still a mirror that&#8217;s pretty much it and remember you can access these cells</p>



<p class="wp-block-paragraph">in constant time which we&#8217;ll talk about more in a future video pretty nice how do you delete</p>



<p class="wp-block-paragraph">uh an edge let&#8217;s pretend that we wanted to delete uh the connection between the five and the three</p>



<p class="wp-block-paragraph">so i&#8217;m going to put maybe like a little squiggly line right here squiggly line saying that that</p>



<p class="wp-block-paragraph">edge is gone i can&#8217;t actually erase that because this is a i guess i could draw white over it but</p>



<p class="wp-block-paragraph">you would still see that the blue lines are covered so the five and three connection is</p>



<p class="wp-block-paragraph">gone now how do</p>



<p class="wp-block-paragraph">and three connection is gone now how do we do that in inside the adjacency matrix again just look at</p>



<p class="wp-block-paragraph">the uh row five column three change that one to a zero and then row three column five change that</p>



<p class="wp-block-paragraph">also to a zero oops not a nine that&#8217;s how you get rid of something so you add something uh by just</p>



<p class="wp-block-paragraph">changing a number you get rid of something by just changing a number self connects are pretty easy</p>



<p class="wp-block-paragraph">um and then of course after you make the matrix you want to just double check that you did it</p>



<p class="wp-block-paragraph">correctly I&#8217;m not going to do that right now</p>



<p class="wp-block-paragraph">check that you did it correctly i&#8217;m not going to do that right now maybe this is a good exercise</p>



<p class="wp-block-paragraph">for you at home you can just kind of like look and try to find my mistakes because that&#8217;s hilarious</p>



<p class="wp-block-paragraph">right um what else can i tell you uh this particular scheme does not support um parallel</p>



<p class="wp-block-paragraph">edges or edges that start at the same start node and end at the same end node as well i&#8217;m not</p>



<p class="wp-block-paragraph">really describing that very well so for example what if i had this three node that is connected</p>



<p class="wp-block-paragraph">to the 2 node and I want it</p>



<p class="wp-block-paragraph">that is connected to the two node and I wanted to add a second connection for some reason like</p>



<p class="wp-block-paragraph">there are reasons to do that I want to have another edge going from three to two and from</p>



<p class="wp-block-paragraph">two to three so now this is a parallel edge it&#8217;s the same it&#8217;s an edge that connects the same two</p>



<p class="wp-block-paragraph">nodes as some other edge how can I represent that inside of this matrix right now I can&#8217;t</p>



<p class="wp-block-paragraph">but one way to do this is to say that every cell where&#8217;s the three and the two there it is every</p>



<p class="wp-block-paragraph">cell in your matrix is not a one or a zero integer but every cell</p>



<p class="wp-block-paragraph">or a zero integer but every cell is its own uh individual linked list or array or vector or</p>



<p class="wp-block-paragraph">something that can hold multiple numbers so just to add a little notation here if if that&#8217;s what</p>



<p class="wp-block-paragraph">i mean then i can say well we&#8217;ll just say that there are two edges by saying that cell has an</p>



<p class="wp-block-paragraph">array of two numbers each number representing a connection not the not the greatest way to</p>



<p class="wp-block-paragraph">to represent it, but in our future</p>



<p class="wp-block-paragraph">greatest way to represent it. But in our future videos, we&#8217;re going to do like directed graphs</p>



<p class="wp-block-paragraph">and weighted graphs. It&#8217;ll make a little bit more sense. But long story short, this is how you do it.</p>



<p class="wp-block-paragraph">Let&#8217;s see. We did 20 minutes for this video. I think I&#8217;m feeling okay. There&#8217;s lots of properties</p>



<p class="wp-block-paragraph">and other stuff that we can talk about with graphs. But for now, I&#8217;m just going to stop right</p>



<p class="wp-block-paragraph">here. Thank you so much for watching this video. I hope you learned a little bit of stuff and had</p>



<p class="wp-block-paragraph">a little bit of fun. Tell your friends and I&#8217;ll see you in the next video.</p>



<p class="wp-block-paragraph">next video how do i stop the recording hey everybody thanks for watching this video again</p>



<p class="wp-block-paragraph">from the bottom of my heart i really appreciate it i do hope you did learn something and have some</p>



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



<p class="wp-block-paragraph">channel or these videos or whatever it is you do on the current social media website that you&#8217;re</p>



<p class="wp-block-paragraph">looking at right now it would really mean the world to me and it&#8217;ll help make more videos</p>



<p class="wp-block-paragraph">and</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 do me a kindness</p>



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



<p class="wp-block-paragraph">wake up because i know somebody subscribed or followed it just wakes me up and i get filled</p>



<p class="wp-block-paragraph">with joy that&#8217;s exactly what happens every single time so you could do it as a nice favor to me or</p>



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



<p class="wp-block-paragraph">just subscribe and then I&#8217;ll just wake up.</p>



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



<p class="wp-block-paragraph">of the screen right now 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 it&#8217;ll take you to my</p>



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



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



<p class="wp-block-paragraph">clarifications or erratics</p>



<p class="wp-block-paragraph">uh, clarifications or errata or just future videos that you want to see, please leave a comment. Or</p>



<p class="wp-block-paragraph">if you just want to say, Hey, what&#8217;s up, what&#8217;s going on? You know, just send me a comment,</p>



<p class="wp-block-paragraph">whatever. I also wake up for those in the middle of the night. I get, I wake up in a cold sweat</p>



<p class="wp-block-paragraph">and I&#8217;m like, it would really, it would really mean the world to me. I would really appreciate</p>



<p class="wp-block-paragraph">it. So again, thank you so much for watching this video and, um, enjoy the cool music as,</p>



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



<p class="wp-block-paragraph">Thanks for watching!</p>
<p>The post <a href="https://www.NeuralLantern.com/how-to-represent-an-undirected-unweighted-graph-with-an-adjacency-matrix/">How to Represent an Undirected Unweighted Graph with an Adjacency Matrix</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-undirected-unweighted-graph-with-an-adjacency-matrix/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
