MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / resolveSubgraphIdPath

Method resolveSubgraphIdPath

src/LGraph.ts:1578–1592  ·  view source on GitHub ↗

* Resolve a path of subgraph node IDs into a list of subgraph nodes. * Not intended to be run from subgraphs. * @param nodeIds An ordered list of node IDs, from the root graph to the most nested subgraph node * @returns An ordered list of nested subgraph nodes.

(nodeIds: readonly NodeId[])

Source from the content-addressed store, hash-verified

1576 * @returns An ordered list of nested subgraph nodes.
1577 */
1578 resolveSubgraphIdPath(nodeIds: readonly NodeId[]): SubgraphNode[] {
1579 const result: SubgraphNode[] = []
1580 let currentGraph: GraphOrSubgraph = this.rootGraph
1581
1582 for (const nodeId of nodeIds) {
1583 const node: LGraphNode | null = currentGraph.getNodeById(nodeId)
1584 if (!node) throw new Error(`Node [${nodeId}] not found. ID Path: ${nodeIds.join(":")}`)
1585 if (!node.isSubgraphNode()) throw new Error(`Node [${nodeId}] is not a SubgraphNode. ID Path: ${nodeIds.join(":")}`)
1586
1587 result.push(node)
1588 currentGraph = node.subgraph
1589 }
1590
1591 return result
1592 }
1593
1594 /**
1595 * Creates a Object containing all the info about this graph, it can be serialized

Callers 1

getInnerNodesMethod · 0.80

Calls 2

getNodeByIdMethod · 0.65
isSubgraphNodeMethod · 0.45

Tested by

no test coverage detected