v2026.6.1
All Bundles
Bundle Classic AI algorithms: graph search, adversarial game search, optimization and tabular reinforcement learning (-lib ai)

Graph

Weighted directed graph over integer node ids 0..n-1, stored as compact per-node adjacency lists that grow automatically. For an undirected edge add both directions.

Example

graph := Graph->New(4);
graph->AddEdge(0, 1, 2.5);
graph->AddEdge(1, 3, 1.0);
result := Dijkstra->FindPath(graph, 0, 3);

Operations

AddEdge #

Adds a directed weighted edge.

method : public : AddEdge(src:Int, to:Int, weight:Float) ~ Bool

Parameters

NameTypeDescription
srcIntsource node id
toIntdestination node id
weightFloatedge weight (>= 0 for the shortest-path searches)

Return

TypeDescription
Booltrue if the edge was added, false on an invalid node id

GetNumEdges #

Gets the number of edges.

method : public : GetNumEdges() ~ Int

Return

TypeDescription
Intedge count

GetNumNodes #

Gets the number of nodes.

method : public : GetNumNodes() ~ Int

Return

TypeDescription
Intnode count

New # constructor

Constructor

New(num_nodes:Int)

Parameters

NameTypeDescription
num_nodesIntnumber of nodes (ids 0..num_nodes-1)