chore(i8n,learn): processed translations
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
15047f2d90
commit
e5c44a3ae5
@ -1,48 +1,50 @@
|
||||
---
|
||||
id: 587d8256367417b2b2512c77
|
||||
title: 邻接名单
|
||||
title: Adjacency List
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
forumTopicId: 301620
|
||||
dashedName: adjacency-list
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
图表可以以不同方式表示。这里我们描述一种方法,称为<dfn>邻接列表</dfn> 。邻接列表本质上是项目符号列表,其中左侧是节点,右侧列出它所连接的所有其他节点。下面是邻接列表的表示。
|
||||
Graphs can be represented in different ways. Here we describe one way, which is called an <dfn>adjacency list</dfn>. An adjacency list is essentially a bulleted list where the left side is the node and the right side lists all the other nodes it's connected to. Below is a representation of an adjacency list.
|
||||
|
||||
> Node1:Node2,Node3
|
||||
> Node2:Node1
|
||||
> Node3:Node1
|
||||
<blockquote>Node1: Node2, Node3<br>Node2: Node1<br>Node3: Node1</blockquote>
|
||||
|
||||
以上是无向图,因为`Node1`连接到`Node2`和`Node3` ,并且该信息与`Node2`和`Node3`显示的连接一致。有向图的邻接列表意味着列表的每一行都显示方向。如果指示上述内容,那么`Node2: Node1`将意味着有向边缘从`Node2`指向`Node1` 。我们可以将上面的无向图表示为邻接列表,方法是将其放在JavaScript对象中。
|
||||
Above is an undirected graph because `Node1` is connected to `Node2` and `Node3`, and that information is consistent with the connections `Node2` and `Node3` show. An adjacency list for a directed graph would mean each row of the list shows direction. If the above was directed, then `Node2: Node1` would mean there the directed edge is pointing from `Node2` towards `Node1`. We can represent the undirected graph above as an adjacency list by putting it within a JavaScript object.
|
||||
|
||||
> var undirectedG = {
|
||||
> 节点1:\[“Node2”,“Node3”],
|
||||
> Node2:\[“Node1”],
|
||||
> Node3:\[“Node1”]
|
||||
> };
|
||||
```js
|
||||
var undirectedG = {
|
||||
Node1: ["Node2", "Node3"],
|
||||
Node2: ["Node1"],
|
||||
Node3: ["Node1"]
|
||||
};
|
||||
```
|
||||
|
||||
这也可以更简单地表示为一个数组,其中节点只有数字而不是字符串标签。
|
||||
This can also be more simply represented as an array where the nodes just have numbers rather than string labels.
|
||||
|
||||
> var undirectedGArr = \[
|
||||
> \[1,2],#Node1
|
||||
> \[0],#Node2
|
||||
> \[0] #Node3
|
||||
> ]。
|
||||
```js
|
||||
var undirectedGArr = [
|
||||
[1, 2], // Node1
|
||||
[0], // Node2
|
||||
[0] // Node3
|
||||
];
|
||||
```
|
||||
|
||||
# --instructions--
|
||||
|
||||
创建一个社交网络作为无向图,其中有4个节点/人名为`James` , `Jill` , `Jenny`和`Jeff` 。詹姆斯和杰夫,吉尔和珍妮以及杰夫和珍妮之间存在边缘/关系。
|
||||
Create a social network as an undirected graph with 4 nodes/people named `James`, `Jill`, `Jenny`, and `Jeff`. There are edges/relationships between James and Jeff, Jill and Jenny, and Jeff and Jenny.
|
||||
|
||||
# --hints--
|
||||
|
||||
`undirectedAdjList`应该只包含四个节点。
|
||||
`undirectedAdjList` should only contain four nodes.
|
||||
|
||||
```js
|
||||
assert(Object.keys(undirectedAdjList).length === 4);
|
||||
```
|
||||
|
||||
`Jeff`和`James`之间应该有优势。
|
||||
There should be an edge between `Jeff` and `James`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -51,7 +53,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`Jill`和`Jenny`之间应该有一个优势。
|
||||
There should be an edge between `Jill` and `Jenny`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -60,7 +62,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`Jeff`和`Jenny`之间应该有优势。
|
||||
There should be an edge between `Jeff` and `Jenny`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
Reference in New Issue
Block a user