From c21c9f0acbd39a09de83fdac6ca202ed85c030de Mon Sep 17 00:00:00 2001 From: Harsh Savergaonkar Date: Thu, 27 Feb 2020 18:24:11 +0530 Subject: [PATCH] Added meaning of ones in adjacency matrices (#37048) * Added meaning of ones in the matrix * Apply suggestions from code review Co-Authored-By: Oliver Eyton-Williams * fix: add slash to avoid markdown lint error Co-authored-by: mrugesh <1884376+raisedadead@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams --- .../data-structures/adjacency-matrix.english.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/adjacency-matrix.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/adjacency-matrix.english.md index 6fab7e4976..b50f740edb 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/adjacency-matrix.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/adjacency-matrix.english.md @@ -9,9 +9,17 @@ forumTopicId: 301621
Another way to represent a graph is to put it in an adjacency matrix. -An adjacency matrix is a two-dimensional (2D) array where each nested array has the same number of elements as the outer array. In other words, it is a matrix or grid of numbers, where the numbers represent the edges. Zeros mean there is no edge or relationship. -
1 2 3
------
1 | 0 1 1
2 | 1 0 0
3 | 1 0 0
-Above is a very simple, undirected graph where you have three nodes, where the first node is connected to the second and third node. Note: The numbers to the top and left of the matrix are just labels for the nodes. +An adjacency matrix is a two-dimensional (2D) array where each nested array has the same number of elements as the outer array. In other words, it is a matrix or grid of numbers, where the numbers represent the edges. + +Note: The numbers to the top and left of the matrix are just labels for the nodes. Inside the matrix, ones mean there exists an edge between the vertices (nodes) representing the row and column. Finally, zeros mean there is no edge or relationship. +
+    1 2 3
+  \------
+1 | 0 1 1
+2 | 1 0 0
+3 | 1 0 0
+
+Above is a very simple, undirected graph where you have three nodes, where the first node is connected to the second and third node. Below is a JavaScript implementation of the same thing. ```js