ComputeGraph

interface ComputeGraph(source)

Interface for managing a computational graph with nodes and edges. This represents the core data structure for graph-based model execution.

Inheritors

Properties

Link copied to clipboard
abstract val edges: List<GraphEdge>

All edges in the graph

Link copied to clipboard
abstract val nodes: List<GraphNode>

All nodes in the graph

Functions

Link copied to clipboard
abstract fun addEdge(edge: GraphEdge): GraphEdge

Adds a new edge connecting two nodes

Link copied to clipboard
abstract fun addNode(node: GraphNode): GraphNode

Adds a new node to the graph

Link copied to clipboard
abstract fun clear()

Clears all nodes and edges

Link copied to clipboard
abstract fun copy(): ComputeGraph

Creates a copy of this graph

Link copied to clipboard
abstract fun getInputNodes(): List<GraphNode>

Gets all input nodes (nodes with no incoming edges)

abstract fun getInputNodes(node: GraphNode): List<GraphNode>

Gets nodes that are inputs to the given node

Link copied to clipboard
abstract fun getOutputNodes(): List<GraphNode>

Gets all output nodes (nodes with no outgoing edges)

abstract fun getOutputNodes(node: GraphNode): List<GraphNode>

Gets nodes that receive output from the given node

Link copied to clipboard

Returns nodes in topological order for execution

Link copied to clipboard
abstract fun removeEdge(edge: GraphEdge): Boolean

Removes an edge from the graph

Link copied to clipboard
abstract fun removeNode(node: GraphNode): Boolean

Removes a node and all connected edges from the graph

Link copied to clipboard
fun ComputeGraph.toGraphviz(rankdir: String = "LR"): String

Convenience extension to get Graphviz DOT text directly from a ComputeGraph.

Link copied to clipboard
abstract fun validate(): ValidationResult

Validates the graph structure (checks for cycles, etc.)