interstellar 0.2.0

A high-performance graph database with Gremlin-style traversals and GQL query language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
//! Performance edge case tests for Gremlin traversal operations.
//!
//! Phase 5 of the integration test strategy. Tests for:
//!
//! - Large result set handling (5+ tests)
//! - Barrier step memory behavior (5+ tests)
//! - Streaming vs buffered execution (5+ tests)
//!
//! These tests verify correctness under performance-sensitive conditions
//! rather than measuring actual performance (benchmarks handle that).

#![allow(unused_variables)]

use std::collections::HashMap;

use interstellar::p;
use interstellar::storage::Graph;
use interstellar::traversal::__;
use interstellar::value::{Value, VertexId};

use crate::common::graphs::create_large_graph;

// =============================================================================
// Test Fixtures for Large Graphs
// =============================================================================

/// Creates a graph with the specified number of vertices.
/// Each vertex has an "index" property with its creation order.
fn create_large_vertex_graph(count: usize) -> Graph {
    let graph = Graph::new();
    for i in 0..count {
        let mut props = HashMap::new();
        props.insert("index".to_string(), Value::Int(i as i64));
        props.insert("name".to_string(), Value::String(format!("vertex_{}", i)));
        props.insert(
            "category".to_string(),
            Value::String(format!("cat_{}", i % 10)),
        );
        graph.add_vertex("node", props);
    }
    graph
}

/// Creates a linear chain graph: v0 -> v1 -> v2 -> ... -> vN
fn create_chain_graph(length: usize) -> (Graph, VertexId, VertexId) {
    let graph = Graph::new();
    let mut prev_id: Option<VertexId> = None;
    let mut first_id: Option<VertexId> = None;
    let mut last_id: Option<VertexId> = None;

    for i in 0..length {
        let mut props = HashMap::new();
        props.insert("index".to_string(), Value::Int(i as i64));
        props.insert("depth".to_string(), Value::Int(i as i64));
        let id = graph.add_vertex("node", props);

        if first_id.is_none() {
            first_id = Some(id);
        }
        last_id = Some(id);

        if let Some(prev) = prev_id {
            graph.add_edge(prev, id, "next", HashMap::new()).unwrap();
        }
        prev_id = Some(id);
    }

    (graph, first_id.unwrap(), last_id.unwrap())
}

/// Creates a dense graph where each vertex connects to multiple others.
/// Vertices 0..count, each connects to (i+1)%count, (i+2)%count, etc.
fn create_dense_graph(vertex_count: usize, edges_per_vertex: usize) -> Graph {
    let graph = Graph::new();
    let mut ids = Vec::with_capacity(vertex_count);

    // Create vertices
    for i in 0..vertex_count {
        let mut props = HashMap::new();
        props.insert("index".to_string(), Value::Int(i as i64));
        let id = graph.add_vertex("node", props);
        ids.push(id);
    }

    // Create edges
    for i in 0..vertex_count {
        for j in 1..=edges_per_vertex {
            let target = (i + j) % vertex_count;
            if target != i {
                let _ = graph.add_edge(ids[i], ids[target], "connects", HashMap::new());
            }
        }
    }

    graph
}

/// Creates a graph with vertices having diverse property values for aggregation tests.
fn create_aggregation_graph(count: usize) -> Graph {
    let graph = Graph::new();
    for i in 0..count {
        let mut props = HashMap::new();
        props.insert("index".to_string(), Value::Int(i as i64));
        props.insert("value".to_string(), Value::Int((i * 7 % 100) as i64));
        props.insert(
            "group".to_string(),
            Value::String(format!("group_{}", i % 5)),
        );
        props.insert("priority".to_string(), Value::Int((i % 3) as i64));
        graph.add_vertex("item", props);
    }
    graph
}

// =============================================================================
// Large Result Set Handling Tests
// =============================================================================

/// Verifies traversal handles 1000+ vertices correctly.
#[test]
fn handles_thousand_vertices() {
    let graph = create_large_vertex_graph(1000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let count = g.v().count();
    assert_eq!(count, 1000);

    let results = g.v().to_list();
    assert_eq!(results.len(), 1000);
}

/// Verifies traversal handles 10,000 vertices correctly.
#[test]
fn handles_ten_thousand_vertices() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let count = g.v().count();
    assert_eq!(count, 10_000);

    // Verify we can filter and still get correct results
    let filtered_count = g.v().has_where("index", p::lt(5000)).count();
    assert_eq!(filtered_count, 5000);
}

/// Verifies limit works correctly with large result sets.
#[test]
fn limit_on_large_result_set() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Limit should stop early, not process all 10k vertices
    let limited = g.v().limit(10).to_list();
    assert_eq!(limited.len(), 10);

    // Verify limit at different points
    let limited_100 = g.v().limit(100).to_list();
    assert_eq!(limited_100.len(), 100);

    let limited_1000 = g.v().limit(1000).to_list();
    assert_eq!(limited_1000.len(), 1000);
}

/// Verifies skip + limit (pagination) works correctly.
#[test]
fn pagination_on_large_result_set() {
    let graph = create_large_vertex_graph(1000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Simulate pagination: page size 100
    let page1 = g.v().range(0, 100).to_list();
    let page2 = g.v().range(100, 200).to_list();
    let page3 = g.v().range(200, 300).to_list();

    assert_eq!(page1.len(), 100);
    assert_eq!(page2.len(), 100);
    assert_eq!(page3.len(), 100);

    // Pages should be disjoint
    let page1_ids: std::collections::HashSet<_> =
        page1.iter().filter_map(|v| v.as_vertex_id()).collect();
    let page2_ids: std::collections::HashSet<_> =
        page2.iter().filter_map(|v| v.as_vertex_id()).collect();

    assert!(
        page1_ids.is_disjoint(&page2_ids),
        "Pages should not overlap"
    );
}

/// Verifies dedup handles large result sets with many duplicates.
#[test]
fn dedup_on_large_result_set_with_duplicates() {
    let graph = create_dense_graph(100, 10);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Navigate out twice - creates many duplicates
    let with_dups = g.v().out().out().to_list();
    let without_dups = g.v().out().out().dedup().to_list();

    // Dedup should significantly reduce count
    assert!(
        without_dups.len() <= with_dups.len(),
        "Dedup should reduce or maintain count"
    );
    assert!(
        without_dups.len() <= 100,
        "Should have at most 100 unique vertices"
    );
}

/// Verifies count() works correctly without materializing all results.
#[test]
fn count_on_large_result_set() {
    let graph = create_large_vertex_graph(50_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Count should work without OOM
    let count = g.v().count();
    assert_eq!(count, 50_000);

    // Count with filter
    let filtered_count = g.v().has_where("index", p::gte(25_000)).count();
    assert_eq!(filtered_count, 25_000);
}

// =============================================================================
// Barrier Step Memory Behavior Tests
// =============================================================================

/// Verifies order() (a barrier step) works correctly with large data.
#[test]
fn order_barrier_with_large_data() {
    let graph = create_large_vertex_graph(5000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // order() must buffer all results before emitting
    let ordered = g
        .v()
        .values("index")
        .order()
        .by_asc()
        .build()
        .limit(10)
        .to_list();

    assert_eq!(ordered.len(), 10);

    // Verify correct ordering (should be 0-9)
    let indices: Vec<i64> = ordered.iter().filter_map(|v| v.as_i64()).collect();
    assert_eq!(indices, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
}

/// Verifies order().by_desc() correctly orders large data.
#[test]
fn order_desc_barrier_with_large_data() {
    let graph = create_large_vertex_graph(5000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let ordered = g
        .v()
        .values("index")
        .order()
        .by_desc()
        .build()
        .limit(10)
        .to_list();

    assert_eq!(ordered.len(), 10);

    // Verify descending order (should be 4999, 4998, ...)
    let indices: Vec<i64> = ordered.iter().filter_map(|v| v.as_i64()).collect();
    assert_eq!(
        indices,
        vec![4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990]
    );
}

/// Verifies group() (a barrier step) handles large data correctly.
#[test]
fn group_barrier_with_large_data() {
    let graph = create_aggregation_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Group by "group" property (5 unique values)
    let grouped = g.v().group().by_key("group").by_value().build().to_list();

    assert_eq!(grouped.len(), 1);

    if let Value::Map(map) = &grouped[0] {
        // Should have 5 groups
        assert_eq!(map.len(), 5);

        // Each group should have 2000 elements (10000 / 5)
        for (key, value) in map.iter() {
            if let Value::List(list) = value {
                assert_eq!(
                    list.len(),
                    2000,
                    "Each group should have 2000 elements, got {} for key {:?}",
                    list.len(),
                    key
                );
            }
        }
    }
}

/// Verifies group_count() (a barrier step) handles large data correctly.
#[test]
fn group_count_barrier_with_large_data() {
    let graph = create_aggregation_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let counts = g.v().group_count().by_key("priority").build().to_list();

    assert_eq!(counts.len(), 1);

    if let Value::Map(map) = &counts[0] {
        // 3 priority levels (0, 1, 2)
        assert_eq!(map.len(), 3);

        // Each priority should have ~3333 elements
        let total: i64 = map.values().filter_map(|v| v.as_i64()).sum();
        assert_eq!(total, 10_000);
    }
}

/// Verifies sum() (a barrier step) handles large numeric data.
#[test]
fn sum_barrier_with_large_data() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let sum = g.v().values("index").sum();

    // Sum of 0..10000 = (n-1)*n/2 = 9999*10000/2 = 49995000
    assert_eq!(sum, Value::Int(49_995_000));
}

/// Verifies min/max (barrier steps) handle large data.
#[test]
fn min_max_barrier_with_large_data() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let min = g.v().values("index").min();
    let max = g.v().values("index").max();

    assert_eq!(min, Some(Value::Int(0)));
    assert_eq!(max, Some(Value::Int(9999)));
}

// =============================================================================
// Streaming vs Buffered Execution Tests
// =============================================================================

/// Verifies that filter steps stream (don't buffer all results).
#[test]
fn filter_streams_without_buffering() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Filter + limit should not process all 10k vertices
    // (We can't directly test this, but we verify correctness)
    let results = g.v().has_where("index", p::lt(100)).limit(5).to_list();

    assert_eq!(results.len(), 5);

    // Verify all results match filter
    for r in &results {
        if let Some(vid) = r.as_vertex_id() {
            // Results should have index < 100
        }
    }
}

/// Verifies navigation steps stream correctly.
#[test]
fn navigation_streams_without_buffering() {
    let (graph, start, _end) = create_chain_graph(1000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Navigate through chain with limit - should stop early
    let results = g
        .v_ids([start])
        .repeat(__.out())
        .times(1000) // Would traverse entire chain
        .emit()
        .limit(10) // But we only want 10
        .to_list();

    assert_eq!(results.len(), 10);
}

/// Verifies that non-barrier chains maintain streaming behavior.
#[test]
fn non_barrier_chain_streams() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Chain of non-barrier steps should stream
    let results = g
        .v()
        .has_label("node")
        .has_where("index", p::lt(1000))
        .values("name")
        .limit(5)
        .to_list();

    assert_eq!(results.len(), 5);
}

/// Verifies barrier step forces buffering, but subsequent steps stream again.
#[test]
fn barrier_then_stream() {
    let graph = create_aggregation_graph(1000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // order() buffers, but limit() after should work correctly
    let results = g
        .v()
        .values("value")
        .order()
        .by_asc()
        .build()
        .limit(10)
        .to_list();

    assert_eq!(results.len(), 10);

    // Should be the 10 smallest values
    let values: Vec<i64> = results.iter().filter_map(|v| v.as_i64()).collect();
    for i in 1..values.len() {
        assert!(values[i - 1] <= values[i], "Should be in ascending order");
    }
}

/// Verifies count() doesn't require materializing list.
#[test]
fn count_optimized_execution() {
    let graph = create_large_vertex_graph(100_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Count should work efficiently
    let count = g.v().count();
    assert_eq!(count, 100_000);

    // Count after filter
    let filtered = g.v().has_where("index", p::lt(50_000)).count();
    assert_eq!(filtered, 50_000);
}

// =============================================================================
// Edge Cases with Large Data
// =============================================================================

/// Verifies empty result handling with large graph.
#[test]
fn empty_result_from_large_graph() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Filter that matches nothing
    let results = g.v().has_where("index", p::gt(100_000)).to_list();
    assert!(results.is_empty());

    let count = g.v().has_where("index", p::gt(100_000)).count();
    assert_eq!(count, 0);
}

/// Verifies single result extraction from large graph.
#[test]
fn single_result_from_large_graph() {
    let graph = create_large_vertex_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Get exactly one vertex
    let result = g.v().has_where("index", p::eq(5000i64)).one();
    assert!(result.is_ok());
}

/// Verifies deep traversal in chain graph.
#[test]
fn deep_traversal_in_chain() {
    let (graph, start, end) = create_chain_graph(100);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Traverse entire chain
    let final_vertex = g
        .v_ids([start])
        .repeat(__.out())
        .times(99) // 99 hops to reach end
        .to_list();

    assert_eq!(final_vertex.len(), 1);
    assert_eq!(final_vertex[0].as_vertex_id(), Some(end));
}

/// Verifies path tracking with large traversal.
#[test]
fn path_tracking_large_traversal() {
    let (graph, start, _end) = create_chain_graph(50);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    let paths = g
        .v_ids([start])
        .with_path()
        .repeat(__.out())
        .times(10)
        .path()
        .to_list();

    assert_eq!(paths.len(), 1);

    if let Value::List(path) = &paths[0] {
        // Path should have 11 elements (start + 10 hops)
        assert_eq!(path.len(), 11);
    }
}

/// Verifies aggregation accuracy with large data.
#[test]
fn aggregation_accuracy_large_data() {
    let graph = create_aggregation_graph(10_000);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Calculate expected sum of "value" property
    // value = (i * 7) % 100 for i in 0..10000
    let expected_sum: i64 = (0..10_000i64).map(|i| (i * 7) % 100).sum();

    let actual_sum = g.v().values("value").sum();
    assert_eq!(actual_sum, Value::Int(expected_sum));
}

// =============================================================================
// Large Graph Fixture Tests (using create_large_graph from common fixtures)
// =============================================================================

/// Verifies create_large_graph fixture produces correct structure.
#[test]
fn large_graph_fixture_structure() {
    let graph = create_large_graph(1000, 5);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Verify vertex count
    let vertex_count = g.v().count();
    assert_eq!(vertex_count, 1000);

    // Verify label distribution (type_a, type_b, type_c in 1:1:1 ratio)
    let type_a_count = g.v().has_label("type_a").count();
    let type_b_count = g.v().has_label("type_b").count();
    let type_c_count = g.v().has_label("type_c").count();

    // Each type should have ~333 vertices (1000/3)
    assert!(type_a_count >= 333 && type_a_count <= 334);
    assert!(type_b_count >= 333 && type_b_count <= 334);
    assert!(type_c_count >= 333 && type_c_count <= 334);
}

/// Verifies large graph property diversity.
#[test]
fn large_graph_fixture_properties() {
    let graph = create_large_graph(500, 3);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // All vertices should have "index" property
    let with_index = g.v().has("index").count();
    assert_eq!(with_index, 500);

    // Verify group distribution (10 groups: group_0 through group_9)
    let groups = g.v().values("group").dedup().to_list();
    assert_eq!(groups.len(), 10);

    // Verify priority distribution (5 priorities: 0-4)
    let priorities = g.v().values("priority").dedup().to_list();
    assert_eq!(priorities.len(), 5);

    // Verify active boolean property
    let active_count = g.v().has_value("active", true).count();
    let inactive_count = g.v().has_value("active", false).count();
    // Half should be active (even indices), half inactive
    assert_eq!(active_count, 250);
    assert_eq!(inactive_count, 250);
}

/// Verifies large graph edge diversity.
#[test]
fn large_graph_fixture_edge_labels() {
    let graph = create_large_graph(100, 6);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Verify edge labels (edge_a, edge_b, edge_c)
    let edge_a = g.e().has_label("edge_a").count();
    let edge_b = g.e().has_label("edge_b").count();
    let edge_c = g.e().has_label("edge_c").count();

    // Each edge type should have roughly 1/3 of edges
    let total_edges = edge_a + edge_b + edge_c;
    assert!(total_edges > 0);

    // All edges should have weight property
    let edges_with_weight = g.e().has("weight").count();
    assert_eq!(edges_with_weight, total_edges);
}

/// Verifies traversal through large graph with mixed labels.
#[test]
fn large_graph_traversal_mixed_labels() {
    let graph = create_large_graph(200, 4);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Start from type_a vertices, traverse via edge_b, reach type_c
    let results = g
        .v()
        .has_label("type_a")
        .limit(10)
        .out_labels(&["edge_b"])
        .has_label("type_c")
        .dedup()
        .to_list();

    // May or may not have results depending on graph topology
    let _ = results;
}

/// Verifies aggregation on large graph with diverse properties.
#[test]
fn large_graph_aggregation() {
    let graph = create_large_graph(1000, 3);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Sum of indices 0..1000
    let expected_sum: i64 = (0..1000i64).sum();
    let actual_sum = g.v().values("index").sum();
    assert_eq!(actual_sum, Value::Int(expected_sum));

    // Group count by priority (5 groups, ~200 each)
    let grouped = g.v().group_count().by_key("priority").build().to_list();

    if let Some(Value::Map(map)) = grouped.first() {
        assert_eq!(map.len(), 5);
        let total: i64 = map.values().filter_map(|v| v.as_i64()).sum();
        assert_eq!(total, 1000);
    }
}

/// Verifies filtering by score (Float property) in large graph.
#[test]
fn large_graph_float_filtering() {
    let graph = create_large_graph(500, 2);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Filter by score > 25.0 (score = index * 0.1, so index > 250)
    let high_score_count = g.v().has_where("score", p::gt(25.0f64)).count();
    // Vertices 251-499 should match (249 vertices)
    assert_eq!(high_score_count, 249);
}

/// Verifies deep traversal scales in large graph.
#[test]
fn large_graph_deep_traversal_scaling() {
    let graph = create_large_graph(500, 4);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Start from first vertex and traverse 5 hops
    let start_id = g
        .v()
        .has_where("index", p::eq(0i64))
        .to_list()
        .first()
        .and_then(|v| v.as_vertex_id());

    if let Some(id) = start_id {
        let reachable = g
            .v_ids([id])
            .repeat(__.out())
            .times(5)
            .emit()
            .dedup()
            .count();

        // With 4 edges per vertex, should reach some vertices
        // (actual count depends on graph topology)
        assert!(
            reachable >= 10,
            "Expected at least 10 reachable vertices, got {}",
            reachable
        );
    }
}

/// Verifies order by Float property works with large graph.
#[test]
fn large_graph_order_by_score() {
    let graph = create_large_graph(1000, 2);
    let snapshot = graph.snapshot();
    let g = snapshot.gremlin();

    // Order by score descending, get top 10
    let top_scores = g
        .v()
        .values("score")
        .order()
        .by_desc()
        .build()
        .limit(10)
        .to_list();

    assert_eq!(top_scores.len(), 10);

    // Top score should be (999 * 0.1) = 99.9
    if let Some(Value::Float(top)) = top_scores.first() {
        assert!((*top - 99.9).abs() < 0.01);
    }
}