# core/stores/graph.store.ts

> 30 lines of code and 12 definitions.

Tree: GovLab Docs
Language: typescript
Layer: application
Canonical: https://banes-lab.com/anatomy/docs#file-docs-core-stores-graph-store-ts
Source text: https://banes-lab.com/source/docs/core/stores/graph.store.ts.txt

Listed in [core/stores](https://banes-lab.com/api/source/docs/core/stores.md).

## Definitions

- `GraphStore` (class_declaration, line 3, exported)
- `#nodes` (public_field_definition, line 4, exported)
- `#edges` (public_field_definition, line 5, exported)
- `#visited` (public_field_definition, line 6, exported)
- `#unresolved` (public_field_definition, line 7, exported)
- `unresolved` (method_definition, line 9, exported)
- `bumpUnresolved` (method_definition, line 13, exported)
- `addNode` (method_definition, line 17, exported)
- `pushEdge` (method_definition, line 23, exported)
- `hasVisited` (method_definition, line 27, exported)
- `markVisited` (method_definition, line 31, exported)
- `result` (method_definition, line 35, exported)

## Contained in

- [core/stores](https://banes-lab.com/anatomy/docs/folder-docs-core-stores.md)

## Source

```typescript
import type { CodeEdge, CodeGraph, CodeNode } from "#types/graph.types";

export class GraphStore {
    readonly #nodes = new Map<string, CodeNode>();
    readonly #edges: CodeEdge[] = [];
    readonly #visited = new Set<string>();
    #unresolved = 0;

    public get unresolved(): number {
        return this.#unresolved;
    }

    public bumpUnresolved(): void {
        this.#unresolved += 1;
    }

    public addNode(node: CodeNode): void {
        if (!this.#nodes.has(node.id)) {
            this.#nodes.set(node.id, node);
        }
    }

    public pushEdge(edge: CodeEdge): void {
        this.#edges.push(edge);
    }

    public hasVisited(id: string): boolean {
        return this.#visited.has(id);
    }

    public markVisited(id: string): void {
        this.#visited.add(id);
    }

    public result(): CodeGraph {
        return { edges: this.#edges, nodes: [...this.#nodes.values()] };
    }
}
```
