* Creates a new subgraph definition, and adds it to the graph. * @param data Exported data (typically serialised) to configure the new subgraph with * @returns The newly created subgraph definition.
(data: ExportedSubgraph)
| 1387 | * @returns The newly created subgraph definition. |
| 1388 | */ |
| 1389 | createSubgraph(data: ExportedSubgraph): Subgraph { |
| 1390 | const { id } = data |
| 1391 | |
| 1392 | const subgraph = new Subgraph(this.rootGraph, data) |
| 1393 | this.subgraphs.set(id, subgraph) |
| 1394 | |
| 1395 | // FE: Create node defs |
| 1396 | this.rootGraph.events.dispatch("subgraph-created", { subgraph, data }) |
| 1397 | return subgraph |
| 1398 | } |
| 1399 | |
| 1400 | convertToSubgraph(items: Set<Positionable>): { subgraph: Subgraph, node: SubgraphNode } { |
| 1401 | if (items.size === 0) throw new Error("Cannot convert to subgraph: nothing to convert") |
no test coverage detected