chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@ -1,56 +1,54 @@
---
id: 587d8256367417b2b2512c78
title: 邻接矩阵
title: Adjacency Matrix
challengeType: 1
videoUrl: ''
forumTopicId: 301621
dashedName: adjacency-matrix
---
# --description--
表示图形的另一种方法是将其置于<dfn>邻接矩阵中</dfn> <dfn>邻接矩阵</dfn>是二维2D阵列其中每个嵌套数组具有与外部数组相同数量的元素。换句话说它是数字的矩阵或网格其中数字代表边缘。零意味着没有边缘或关系。
Another way to represent a graph is to put it in an <dfn>adjacency matrix</dfn>. An <dfn>adjacency matrix</dfn> 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.
> 1 2 3
>
> * * *
>
> 1 | 0 1 1
> 2 | 1 0 0
> 3 | 1 0 0
**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.
上面是一个非常简单的无向图,其中有三个节点,第一个节点连接到第二个和第三个节点。 **注意** 矩阵顶部和左侧的数字只是节点的标签。下面是同一件事的JavaScript实现。
<pre>
1 2 3
\------
1 | 0 1 1
2 | 1 0 0
3 | 1 0 0
</pre>
> var adjMat = \[
> \[0,1,1]
> \[1,0,0]
> \[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
var adjMat = [
[0, 1, 1],
[1, 0, 0],
[1, 0, 0]
];
```
> var adjMatDirected = \[
> \[0,1,0]
> \[0,0,1]
> \[0,0,0]
> ]。
Unlike an adjacency list, each "row" of the matrix has to have the same number of elements as nodes in the graph. Here we have a three by three matrix, which means we have three nodes in our graph. A directed graph would look similar. Below is a graph where the first node has an edge pointing toward the second node, and then the second node has an edge pointing to the third node.
图形的边缘也可以有权
```js
var adjMatDirected = [
[0, 1, 0],
[0, 0, 1],
[0, 0, 0]
];
```
<dfn></dfn>
。到目前为止,我们有
<dfn>未加权的</dfn>
边缘,只有存在和缺少边是二进制( `0``1` )。根据您的应用,您可以拥有不同的重量。
Graphs can also have <dfn>weights</dfn> on their edges. So far, we have <dfn>unweighted</dfn> edges where just the presence and lack of edge is binary (`0` or `1`). You can have different weights depending on your application.
# --instructions--
创建具有五个节点的无向​​图的邻接矩阵。该矩阵应该是多维数组。这五个节点在第一和第四节点,第一和第三节点,第三和第五节点以及第四和第五节点之间具有关系。所有边缘权重都是一个。
Create an adjacency matrix of an undirected graph with five nodes. This matrix should be in a multi-dimensional array. These five nodes have relationships between the first and fourth node, the first and third node, the third and fifth node, and the fourth and fifth node. All edge weights are one.
# --hints--
`undirectedAdjList`应该只包含五个节点。
`undirectedAdjList` should only contain five nodes.
```js
assert(
@ -65,25 +63,25 @@ assert(
);
```
第一个和第四个节点之间应该有一条边。
There should be an edge between the first and fourth node.
```js
assert(adjMatUndirected[0][3] === 1 && adjMatUndirected[3][0] === 1);
```
第一个和第三个节点之间应该有一条边。
There should be an edge between the first and third node.
```js
assert(adjMatUndirected[0][2] === 1 && adjMatUndirected[2][0] === 1);
```
第三个和第五个节点之间应该有一条边。
There should be an edge between the third and fifth node.
```js
assert(adjMatUndirected[2][4] === 1 && adjMatUndirected[4][2] === 1);
```
第四个和第五个节点之间应该有一条边。
There should be an edge between the fourth and fifth node.
```js
assert(adjMatUndirected[3][4] === 1 && adjMatUndirected[4][3] === 1);