Skip to content

Commit 487ce4e

Browse files
chtituxclaude
andcommitted
Document buildGraph in gtfs-sqljs skill
Adds a v0.7.0 example for the new directed-graph builder, the edgeCount and edges helpers, and the Graph/EdgeTrip/EdgeData type imports. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 67e08e8 commit 487ce4e

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.claude/skills/gtfs-sqljs/SKILL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,19 @@ const exceptionsForDate = await gtfs.getCalendarDatesForDate('20240115');
258258

259259
// Build ordered stop list across multiple trip variants (express/local, etc.)
260260
const orderedStops = await gtfs.buildOrderedStopList(['TRIP_1', 'TRIP_2', 'TRIP_3']);
261+
262+
// Build a directed stop-to-stop graph from a set of trips (v0.7.0+).
263+
// Edges connect consecutive stops in stop_sequence order (gaps allowed —
264+
// uses LEAD()). Each deduplicated edge carries the list of trips that
265+
// traverse it, with route_id and direction_id attached.
266+
const graph = await gtfs.buildGraph(['TRIP_1', 'TRIP_2']);
267+
// graph: Map<fromStopId, Map<toStopId, { trips: EdgeTrip[] }>>
268+
const edge = graph.get('STOP_A')?.get('STOP_B');
269+
edge?.trips.forEach(t => console.log(t.tripId, t.routeId, t.directionId));
270+
271+
import { edgeCount, edges } from 'gtfs-sqljs';
272+
edgeCount(graph); // total directed edges
273+
for (const { from, to, data } of edges(graph)) { /* ... */ }
261274
```
262275

263276
All query methods support a `limit` filter parameter.
@@ -357,6 +370,9 @@ import {
357370
// Filters
358371
type StopFilters, type RouteFilters, type TripFilters,
359372
type StopTimeFilters, type ShapeFilters,
373+
// Graph (v0.7.0+)
374+
type Graph, type EdgeTrip, type EdgeData,
375+
edgeCount, edges,
360376
// Realtime
361377
type Alert, type VehiclePosition, type TripUpdate, type StopTimeUpdate,
362378
type AlertFilters, type VehiclePositionFilters, type TripUpdateFilters,

0 commit comments

Comments
 (0)