# dumpGraph

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

@shumoku/core · 0.4.0 · function

# dumpGraph

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

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

Serialize a graph to authoring YAML, the inverse of \`YamlParser.parse()\`: \`parse(dumpGraph(g))\` is a fixed point over the schema the parser reads. Hand-rolling this as string concatenation is not safe: any label carrying a newline (a two-line segment name, say) has to be quoted or the document it produces is invalid YAML — and a value the writer forgets to emit is simply gone the next time the text is parsed. Both failure modes are silent. So this delegates quoting and escaping to js-yaml, and spreads the graph rather than listing keys: enumerating is what silently drops a field when the model gains one. Only the three shapes the parser stores differently from how it reads them are converted (\`spec\` on nodes and subgraphs, \`plug\` on link endpoints). The fixed point holds over the schema the parser reads, which is NARROWER than the model. Everything else is written to the document — nothing is dropped here — but is lost the next time that text is parsed: - graph: \`terminations\`, \`exclusions\`, \`attachments\` - node: \`presence\`, \`attachments\`, \`suppressedAttachments\`, \`entityId\`, \`position\`, \`size\`, \`termination\`, \`productId\`, \`provenance\`, \`fieldSources\` - link: \`via\`, \`bends\`, \`rateBps\`, \`metadata\`, \`presence\`, \`provenance\`, \`entityId\` - subgraph: \`entityId\`, \`bounds\`, \`pinPositions\` \`presence\` and \`attachments\` are the ones that bite: an \`'anchor'\` node comes back as a \`'scoop'\` (resolve then keeps a device alive that was only meant to carry identity) and a metrics binding is simply gone. So anything a source mints beyond the authoring schema — the editor, the resolver, the entity registry — must not be round-tripped through the YAML pane. Keep this list honest against the parser. A field the parser stopped reading (or never read) does not announce itself: \`subgraph.identity\` was absent here and unread, so an exported region came back without the key \`resolve()\` clusters regions by — one region became two same-labelled boxes with the members split between them, from a document that looked correct. \`sheets\` is the exception that is NOT written: it is a \`Map\`, which cannot be expressed here without inventing an authoring form for it (see \`pruneUndefined\`). \`lineWidth: -1\` disables line folding: folded output re-parses to the same value, but it makes hand-editing the result confusing.

```
dumpGraph(graph: NetworkGraph): string
```

## パラメーター

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

## 戻り値

```
string
```

[`libs/@shumoku/core/src/parser/serialize.ts:137`](https://github.com/konoe-akitoshi/shumoku/blob/main/libs/@shumoku/core/src/parser/serialize.ts#L137)
