# addLink

Canonical: https://docs.shumoku.dev/ja/library/api/addLink
Language: ja

@shumoku/core · 0.4.0 · function

# addLink

[ソース](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/layout/interaction.ts#L595)

APIの説明は英語のcanonical sourceを表示しています。

Add a link between two ports (existing or new). If fromPortId/toPortId refer to existing ports, use them. If toTarget is a nodeId (no port), create a new port on that node. Returns the updated graph with the new link, or null if invalid.

```
addLink(graph: NetworkGraph, fromPortId: string, toPortId: string): NetworkGraph | null
```

## パラメーター

| 名前 | 型 | 説明 | 既定値 |
| --- | --- | --- | --- |
| `graph` | `NetworkGraph` | 追加説明はありません。 | `—` |
| `fromPortId` | `string` | 追加説明はありません。 | `—` |
| `toPortId` | `string` | 追加説明はありません。 | `—` |

## 戻り値

```
NetworkGraph | null
```

[`libs/@shumoku/core/src/layout/interaction.ts:595`](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/layout/interaction.ts#L595)
