Skip to content

Commit 444d0ff

Browse files
committed
fix(utils): correct ego-network test expectations and add cache to gitignore
- Fix test 'should extract induced subgraph with correct edges': Expected 3 nodes (A, B, C) with 3 edges for triangle graph, not 2 nodes with 1 edge. An induced subgraph includes ALL nodes within radius and ALL edges between them. - Fix test 'should extract union of multiple seed node neighborhoods': Expected 4 nodes (A, B, C, D) not 5. Node E is at distance 2 from A, so should NOT be included with radius 1. - Add /cache to .gitignore (runtime test cache from DiskCacheWriter tests) Original test expectations were incorrect - they didn't match the documented behavior of ego-network extraction (BFS-based k-hop neighborhood with induced subgraph extraction).
1 parent b6538fc commit 444d0ff

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ coverage-reports
1818
# But allow source files in apps/*/coverage/ directories (test infrastructure utilities)
1919
!apps/web/coverage/
2020

21+
# Runtime cache directories
22+
/cache
23+
2124
# Test results and artifacts
2225
test-results
2326
playwright-report*

packages/graph-expansion/src/extraction/ego-network.unit.test.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,14 @@ describe('extractEgoNetwork', () => {
468468

469469
expect(result.ok).toBe(true);
470470
if (result.ok) {
471-
expect(result.value.nodes).toHaveLength(2);
472-
expect(result.value.edges).toHaveLength(1);
473-
expect(result.value.edges[0].source).toBe('A');
474-
expect(result.value.edges[0].target).toBe('B');
471+
// Induced subgraph includes A, B, C (all nodes within 1 hop of A)
472+
// and all edges between them (A->B, A->C, B->C)
473+
expect(result.value.nodes).toHaveLength(3);
474+
expect(result.value.edges).toHaveLength(3);
475+
const ids = result.value.nodes.map(n => n.id);
476+
expect(ids).toContain('A');
477+
expect(ids).toContain('B');
478+
expect(ids).toContain('C');
475479
}
476480
});
477481

@@ -496,6 +500,11 @@ describe('extractEgoNetwork', () => {
496500
describe('extractMultiSourceEgoNetwork', () => {
497501
it('should extract union of multiple seed node neighborhoods', () => {
498502
// Create graph: A -> B, C -> D, B -> E
503+
// With radius 1 from A and C:
504+
// - A's neighborhood: {A, B}
505+
// - C's neighborhood: {C, D}
506+
// - Union: {A, B, C, D}
507+
// Note: E is at distance 2 from A (A->B->E), so NOT included with radius 1
499508
graph.addNode({ id: 'A', label: 'Node A' });
500509
graph.addNode({ id: 'B', label: 'Node B' });
501510
graph.addNode({ id: 'C', label: 'Node C' });
@@ -509,13 +518,13 @@ describe('extractEgoNetwork', () => {
509518

510519
expect(result.ok).toBe(true);
511520
if (result.ok) {
512-
expect(result.value.nodes).toHaveLength(5);
521+
expect(result.value.nodes).toHaveLength(4);
513522
const ids = result.value.nodes.map(n => n.id);
514523
expect(ids).toContain('A');
515524
expect(ids).toContain('B');
516525
expect(ids).toContain('C');
517526
expect(ids).toContain('D');
518-
expect(ids).toContain('E');
527+
expect(ids).not.toContain('E'); // E is at distance 2 from A
519528
}
520529
});
521530

0 commit comments

Comments
 (0)