Extending CRuby with native Graph data type
summary
Adds a native Graph type to CRuby by writing a C extension (ext/adjacency_list_graph.c) that exposes a Graph class via the usual allocation and init hooks, uses the data_Wrap_Struct / data_get_struct helpers, and implements BFS, Dijkstra and MST in C. Handles GC with mark and free callbacks and a temporary trace array when converting C results to Ruby arrays. Benchmarks show dramatic gains — 65k nodes: 10 ms vs 1 min (~100×) — and scales to million‑node graphs where C finishes in hours while Ruby takes orders of magnitude longer.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 4:05Array class
- 10:40Array method
- 12:02Array structure
- 12:26Basic object
- 12:59Error object
- 13:38Array
- 15:07Memory Allocation
- 16:00Arrays
- 16:55Widget
- 18:03initialization
- 18:59widgetstruct
- 20:08ext folder
- 21:52C file
- 22:42allocation
- 23:21free
- 23:48highlevel function
- 24:57garbage collection
- 26:16why
related talks
37mExploring Graphs with Ruby
05m⚡️ Graph Databases with Ruby
41mGraphGen: Conducting Graph Analytics over Relational Databases
01h 01mGeneric Graph Libraries in C++20
29mIntroduction to CRuby source code
29mIntroduction to CRuby source code
35mRuby’s C Extension Problem and How We're Solving It
40mTurbo Rails with Rust
