# What Are the 35 Edge Types in the Understand-Anything Knowledge Graph Schema?

> Explore the 35 edge types in the Understand-Anything knowledge graph schema. Uncover structural, semantic, and dependency edges essential for code graph construction and analysis.

- Repository: [Yuxiang Lin/Understand-Anything](https://github.com/Lum1104/Understand-Anything)
- Tags: api-reference
- Published: 2026-06-01

---

**The Understand-Anything knowledge graph schema defines 35 distinct edge types across structural, semantic, and dependency categories, with the "3S" structural edges (imports, exports, contains) forming the foundational layer required for code graph construction.**

The Understand-Anything repository implements a comprehensive knowledge graph system for code analysis that maps relationships between code entities using 35 semantic edge types. While the complete set spans inheritance patterns, implementation contracts, and semantic dependencies, the core structural foundation consists of three primary edge types known as the **3S edges**. These foundational edges are declared in [`packages/core/src/types.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/types.ts) and validated in [`packages/core/src/schema.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/schema.ts), providing the minimal graph structure necessary to represent how code files relate to each other and their contained symbols.

## The 3S Structural Edge Types

The 3S (Three Structural) edge types represent the minimal set required for a pure structural graph representation. According to the source code in [`packages/core/src/schema.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/schema.ts) and [`packages/core/src/types.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/types.ts), these three edges describe how files import external symbols, export public APIs, and contain child entities.

### imports

The `imports` edge represents a directional relationship where a source file or module imports symbols from a target file. This edge is created by the import-export analyzer when parsing language-specific import statements.

```typescript
import type { GraphEdge } from "@understand-anything/core";

const importEdge: GraphEdge = {
  source: "file:src/app.ts",
  target: "file:src/utils.ts",
  type: "imports",
  direction: "forward",
  weight: 1.0,
};

```

### exports

The `exports` edge connects a file to the symbols it exposes for external consumption. This relationship indicates that the target symbol is publicly accessible from the source module.

```typescript
const exportEdge: GraphEdge = {
  source: "file:src/utils.ts",
  target: "symbol:src/utils.ts:formatDate",
  type: "exports",
  direction: "forward",
  weight: 0.9,
};

```

### contains

The `contains` edge establishes hierarchical containment, linking a parent node (such as a file) to child nodes (such as functions, classes, or variables). The **graph-builder** generates these edges while walking the abstract syntax tree (AST) to discover entities nested within files.

```typescript
const containEdge: GraphEdge = {
  source: "file:src/app.ts",
  target: "function:src/app.ts:main",
  type: "contains",
  direction: "forward",
  weight: 1.0,
};

```

## Extended Structural Relationships

Beyond the core 3S edges, the **Structural** category in [`packages/core/src/types.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/types.ts) includes additional edges that describe code organization patterns. The `inherits` edge represents class inheritance relationships, while the `implements` edge captures interface implementation contracts. These edges extend the structural foundation to support object-oriented hierarchy analysis, though they are not part of the minimal 3S set required for basic graph construction.

## The Complete 35 Edge Type System

While this article focuses on the foundational structural edges, the `EdgeType` union defined in [`packages/core/src/types.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/types.ts) enumerates **35 total edge types** covering semantic dependencies, call relationships, type references, and data flows. The schema validator in [`packages/core/src/schema.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/schema.ts) enforces these type constraints during knowledge graph construction, ensuring that only valid edge types connect entities in the graph database.

The remaining 30 edge types include relationships for semantic analysis, dependency tracking, and cross-reference mapping that operate alongside the structural 3S edges to provide a complete code intelligence graph.

## How the Graph Builder Generates Structural Edges

The **graph-builder** module at [`packages/core/src/analyzer/graph-builder.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/analyzer/graph-builder.ts) automates the creation of structural edges during the analysis phase. When processing a codebase, the builder:

1. Creates `"contains"` edges by traversing ASTs to discover functions and classes declared within each file
2. Invokes language-specific extractors to identify import statements, generating `"imports"` edges between dependent files
3. Analyzes export declarations to construct `"exports"` edges linking modules to their public symbols

This generation process ensures that the 3S structural layer is complete before additional semantic edges are added to the graph.

## Summary

- **The Understand-Anything schema defines 35 edge types** organized into structural, semantic, and dependency categories
- **The 3S edges (imports, exports, contains)** form the foundational structural layer required for any valid knowledge graph
- **Source files**: [`packages/core/src/types.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/types.ts) (type definitions), [`packages/core/src/schema.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/schema.ts) (Zod validation), and [`packages/core/src/analyzer/graph-builder.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/analyzer/graph-builder.ts) (edge generation)
- **Additional structural edges** include `inherits` and `implements` for object-oriented relationship mapping
- **`GraphEdge` objects** require `source`, `target`, `type`, `direction`, and `weight` properties for all 35 edge variants

## Frequently Asked Questions

### What do the 3S edge types represent in Understand-Anything?

The 3S edge types represent the three core **Structural** relationships: `imports` (file-to-file dependencies), `exports` (file-to-symbol public API exposure), and `contains` (parent-to-child hierarchical nesting). These three edges provide the minimal structural graph needed to represent code organization without semantic analysis.

### Where are the 35 edge types defined in the source code?

All 35 edge types are enumerated in the `EdgeType` union within [`packages/core/src/types.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/types.ts). The Zod schema validator in [`packages/core/src/schema.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/schema.ts) references these definitions to validate knowledge graph integrity at runtime.

### How does the graph builder decide which structural edges to create?

The **graph-builder** in [`packages/core/src/analyzer/graph-builder.ts`](https://github.com/Lum1104/Understand-Anything/blob/main/packages/core/src/analyzer/graph-builder.ts) creates `"contains"` edges by walking ASTs to discover nested entities. It creates `"imports"` and `"exports"` edges by delegating to language-specific parsers that analyze import/export declarations in the source code.