<!--
{
  "availability" : [
    "Reality Composer Pro: -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ComputeGraph",
  "identifier" : "/documentation/ComputeGraph/ComputeNodeGraph",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Compute Graph"
    ],
    "preciseIdentifier" : "s:12ComputeGraph0a4NodeB0V"
  },
  "title" : "ComputeNodeGraph"
}
-->

# ComputeNodeGraph

```
struct ComputeNodeGraph
```

## Topics

### Classes

[`class Library`](/documentation/ComputeGraph/ComputeNodeGraph/Library)

A class defining a library of node definitions that can be added to a ComputeNodeGraph

### Structures

[`struct ArrayDefinition`](/documentation/ComputeGraph/ComputeNodeGraph/ArrayDefinition)

[`struct Assembly`](/documentation/ComputeGraph/ComputeNodeGraph/Assembly)

Fully assembled configuration of compute graph nodes.

[`struct DataType`](/documentation/ComputeGraph/ComputeNodeGraph/DataType)

[`struct Edge`](/documentation/ComputeGraph/ComputeNodeGraph/Edge)

[`struct LibraryReference`](/documentation/ComputeGraph/ComputeNodeGraph/LibraryReference)

A Metal library and an optional bundle identifier that locates shader functions.

[`struct Metadata`](/documentation/ComputeGraph/ComputeNodeGraph/Metadata)

[`struct Node`](/documentation/ComputeGraph/ComputeNodeGraph/Node)

[`struct NodeDefinition`](/documentation/ComputeGraph/ComputeNodeGraph/NodeDefinition)

[`struct Pipelines`](/documentation/ComputeGraph/ComputeNodeGraph/Pipelines)

Fully-compiled shaders for a compute graph.

[`struct PipelinesDescriptor`](/documentation/ComputeGraph/ComputeNodeGraph/PipelinesDescriptor)

Specifies the configuration used to compile a set of compute pipelines for a
compute graph effect.

[`struct PointerDefinition`](/documentation/ComputeGraph/ComputeNodeGraph/PointerDefinition)

[`struct PortDefinition`](/documentation/ComputeGraph/ComputeNodeGraph/PortDefinition)

[`struct SamplerSettings`](/documentation/ComputeGraph/ComputeNodeGraph/SamplerSettings)

[`struct Scope`](/documentation/ComputeGraph/ComputeNodeGraph/Scope)

A scope is a named region of memory, indicating where a value lives

[`struct Stage`](/documentation/ComputeGraph/ComputeNodeGraph/Stage)

An execution context within a compute node graph that groups related nodes into a processing phase.

[`struct StateDefinition`](/documentation/ComputeGraph/ComputeNodeGraph/StateDefinition)

A declaration of a named state value and where it lives in the simulation.

[`struct StructureDefinition`](/documentation/ComputeGraph/ComputeNodeGraph/StructureDefinition)

A named structure type, pairing a type name with its in-memory layout.

[`struct StructureLayout`](/documentation/ComputeGraph/ComputeNodeGraph/StructureLayout)

[`struct SwizzleChannels`](/documentation/ComputeGraph/ComputeNodeGraph/SwizzleChannels)

### Initializers

[`init()`](/documentation/ComputeGraph/ComputeNodeGraph/init())

[`init(data: Data) throws`](/documentation/ComputeGraph/ComputeNodeGraph/init(data:))

Creates a graph by decoding a computegraph.

### Instance Properties

[`var edges: [ComputeNodeGraph.Edge]`](/documentation/ComputeGraph/ComputeNodeGraph/edges)

[`var nodes: [ComputeNodeGraph.NodeID : ComputeNodeGraph.Node]`](/documentation/ComputeGraph/ComputeNodeGraph/nodes)

### Instance Methods

[`func addEdge(ComputeNodeGraph.Edge) throws`](/documentation/ComputeGraph/ComputeNodeGraph/addEdge(_:))

[`func addNode(ComputeNodeGraph.Node) throws -> ComputeNodeGraph.NodeID`](/documentation/ComputeGraph/ComputeNodeGraph/addNode(_:))

Adds a node to the graph.

[`func canAddEdge(ComputeNodeGraph.Edge) -> Bool`](/documentation/ComputeGraph/ComputeNodeGraph/canAddEdge(_:))

Returns whether the given edge can be added to the graph.

[`func canAddNode(ComputeNodeGraph.Node) -> Bool`](/documentation/ComputeGraph/ComputeNodeGraph/canAddNode(_:))

Returns whether the given node can be added to the graph.

[`func contains(edge: ComputeNodeGraph.Edge) -> Bool`](/documentation/ComputeGraph/ComputeNodeGraph/contains(edge:))

Returns whether the graph contains the given edge.

[`func contains(node: ComputeNodeGraph.NodeID) -> Bool`](/documentation/ComputeGraph/ComputeNodeGraph/contains(node:))

Returns whether the graph contains a node with the given key.

[`func data(using: ComputeNodeGraph.Format) throws -> Data`](/documentation/ComputeGraph/ComputeNodeGraph/data(using:))

Returns the graph encoded in the specified format.

[`func removeEdge(ComputeNodeGraph.Edge) -> Bool`](/documentation/ComputeGraph/ComputeNodeGraph/removeEdge(_:))

Removes an edge from the graph.

[`func removeNode(ComputeNodeGraph.NodeID) throws`](/documentation/ComputeGraph/ComputeNodeGraph/removeNode(_:))

Removes a node from the graph.

[`func replaceAll(nodes: [ComputeNodeGraph.NodeID : ComputeNodeGraph.Node], edges: [ComputeNodeGraph.Edge]) throws`](/documentation/ComputeGraph/ComputeNodeGraph/replaceAll(nodes:edges:))

Replaces all nodes and edges in the graph with the provided collections.

[`func updateNode(ComputeNodeGraph.Node, forKey: ComputeNodeGraph.NodeID) throws`](/documentation/ComputeGraph/ComputeNodeGraph/updateNode(_:forKey:))

Updates an existing node in the graph.

### Subscripts

[`subscript(ComputeNodeGraph.NodeID) -> ComputeNodeGraph.Node?`](/documentation/ComputeGraph/ComputeNodeGraph/subscript(_:))

Accesses the node associated with the given key.

### Type Aliases

[`typealias NodeID`](/documentation/ComputeGraph/ComputeNodeGraph/NodeID)

### Enumerations

[`enum Format`](/documentation/ComputeGraph/ComputeNodeGraph/Format)

A serialization format used to encode a compute node graph.

[`enum Port`](/documentation/ComputeGraph/ComputeNodeGraph/Port)

[`enum StateType`](/documentation/ComputeGraph/ComputeNodeGraph/StateType)

The shape of a value stored in a compute graph’s state.

[`enum Topology`](/documentation/ComputeGraph/ComputeNodeGraph/Topology)

The primitive topology used to assemble output geometry for an output stage.

[`enum ValueType`](/documentation/ComputeGraph/ComputeNodeGraph/ValueType)

Describes the storage and layout of a port’s value, ranging from Metal primitives
and structures to opaque references and stateful bindings.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)