chore(i8n,learn): processed translations
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
15047f2d90
commit
e5c44a3ae5
@ -1,69 +1,60 @@
|
||||
---
|
||||
id: 587d8256367417b2b2512c79
|
||||
title: 发生率矩阵
|
||||
title: Incidence Matrix
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
forumTopicId: 301644
|
||||
dashedName: incidence-matrix
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
表示图形的另一种方式是将其置于<dfn>关联矩阵中。</dfn> <dfn>入射矩阵</dfn>是二维(2D)阵列。一般而言,关联矩阵在其两个维度之间涉及两个不同类别的对象。这种矩阵类似于邻接矩阵。但是,行和列在这里意味着其他东西。在图表中,我们有边缘和节点。这些将是我们的“两类不同的对象”。该矩阵将使行为节点,列为边。这意味着我们可以拥有不均匀的行数和列数。每列将代表一个独特的边缘。此外,每个边连接两个节点。要显示两个节点之间存在边缘,您将在特定列的两行中放置1。下面是一个3节点图,节点1和节点3之间有一条边。
|
||||
Yet another way to represent a graph is to put it in an <dfn>incidence matrix.</dfn>
|
||||
|
||||
> 1
|
||||
>
|
||||
> * * *
|
||||
>
|
||||
> 1 | 1
|
||||
> 2 | 0
|
||||
> 3 | 1
|
||||
An <dfn>incidence matrix</dfn> is a two-dimensional (2D) array. Generally speaking, an incidence matrix relates two different classes of objects between its two dimensions. This kind of matrix is similar to an adjacency matrix. However, the rows and columns mean something else here.
|
||||
|
||||
以下是具有4个边和4个节点的`incidence matrix`的示例。请记住,列是边,行是节点本身。
|
||||
In graphs, we have edges and nodes. These will be our "two different classes of objects". This matrix will have the rows be the nodes and columns be the edges. This means that we can have an uneven number of rows and columns.
|
||||
|
||||
> 1 2 3 4
|
||||
>
|
||||
> * * *
|
||||
>
|
||||
> 1 | 0 1 1 1
|
||||
> 2 | 1 1 0 0
|
||||
> 3 | 1 0 0 1
|
||||
> 4 | 0 0 1 0
|
||||
Each column will represent a unique edge. Also, each edge connects two nodes. To show that there is an edge between two nodes, you will put a 1 in the two rows of a particular column. Below is a 3 node graph with one edge between node 1 and node 3.
|
||||
|
||||
下面是同一件事的JavaScript实现。
|
||||
<blockquote> 1<br> ---<br>1 | 1<br>2 | 0<br>3 | 1</blockquote>
|
||||
|
||||
> var incMat = \[
|
||||
> \[0,1,1,1],
|
||||
> \[1,1,0,0],
|
||||
> \[1,0,0,1],
|
||||
> \[0,0,1,0]
|
||||
> ]。
|
||||
Here is an example of an `incidence matrix` with 4 edges and 4 nodes. Remember, the columns are the edges and rows are the nodes themselves.
|
||||
|
||||
要制作有向图,请使用`-1`表示离开特定节点的边,使用`1`作为边进入节点。
|
||||
<blockquote> 1 2 3 4<br> --------<br>1 | 0 1 1 1<br>2 | 1 1 0 0<br>3 | 1 0 0 1<br>4 | 0 0 1 0</blockquote>
|
||||
|
||||
> var incMatDirected = \[
|
||||
> \[0,-1,1,-1],
|
||||
> \[-1,1,0,0],
|
||||
> \[1,0,0,1],
|
||||
> \[0,0,-1,0]
|
||||
> ]。
|
||||
Below is a JavaScript implementation of the same thing.
|
||||
|
||||
图形的边缘也可以有权
|
||||
```js
|
||||
var incMat = [
|
||||
[0, 1, 1, 1],
|
||||
[1, 1, 0, 0],
|
||||
[1, 0, 0, 1],
|
||||
[0, 0, 1, 0]
|
||||
];
|
||||
```
|
||||
|
||||
<dfn>重</dfn>
|
||||
To make a directed graph, use `-1` for an edge leaving a particular node and `1` for an edge entering a node.
|
||||
|
||||
。到目前为止,我们有
|
||||
```js
|
||||
var incMatDirected = [
|
||||
[ 0, -1, 1, -1],
|
||||
[-1, 1, 0, 0],
|
||||
[ 1, 0, 0, 1],
|
||||
[ 0, 0, -1, 0]
|
||||
];
|
||||
```
|
||||
|
||||
<dfn>未加权的</dfn>
|
||||
|
||||
边缘,只有存在和缺少边是二进制( `0`或`1` )。根据您的应用,您可以拥有不同的重量。不同的权重表示为大于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. A different weight is represented as numbers greater than 1.
|
||||
|
||||
# --instructions--
|
||||
|
||||
创建具有五个节点和四个边的无向图的关联矩阵。该矩阵应该是多维数组。这五个节点在关系之后具有关系。第一边缘在第一和第二节点之间。第二个边缘位于第二个和第三个节点之间。第三个边缘位于第三个和第五个节点之间。并且四个边缘在第四和第二节点之间。所有边权重均为1,边缘顺序很重要。
|
||||
Create an incidence matrix of an undirected graph with five nodes and four edges. This matrix should be in a multi-dimensional array.
|
||||
|
||||
These five nodes have the following relationships. The first edge is between the first and second node. The second edge is between the second and third node. The third edge is between the third and fifth node. The fourth edge is between the fourth and second node. All edge weights are one and the edge order matters.
|
||||
|
||||
# --hints--
|
||||
|
||||
`incMatUndirected`应该只包含五个节点。
|
||||
`incMatUndirected` should only contain five nodes.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -78,25 +69,25 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
第一个和第二个节点之间应该有第一条边。
|
||||
There should be a first edge between the first and second node.
|
||||
|
||||
```js
|
||||
assert(incMatUndirected[0][0] === 1 && incMatUndirected[1][0] === 1);
|
||||
```
|
||||
|
||||
第二个和第三个节点之间应该有第二条边。
|
||||
There should be a second edge between the second and third node.
|
||||
|
||||
```js
|
||||
assert(incMatUndirected[1][1] === 1 && incMatUndirected[2][1] === 1);
|
||||
```
|
||||
|
||||
第三个和第五个节点之间应该有第三条边。
|
||||
There should be a third edge between the third and fifth node.
|
||||
|
||||
```js
|
||||
assert(incMatUndirected[2][2] === 1 && incMatUndirected[4][2] === 1);
|
||||
```
|
||||
|
||||
第二个和第四个节点之间应该有第四条边。
|
||||
There should be a fourth edge between the second and fourth node.
|
||||
|
||||
```js
|
||||
assert(incMatUndirected[1][3] === 1 && incMatUndirected[3][3] === 1);
|
||||
|
Reference in New Issue
Block a user