# core/factories/graph.factory.ts

> 7 lines of code and 2 definitions.

Tree: GovLab Patterns
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/patterns#file-patterns-core-factories-graph-factory-ts
Source text: https://banes-lab.com/source/patterns/core/factories/graph.factory.ts.txt

Listed in [core/factories](https://banes-lab.com/api/source/patterns/core/factories.md), after [core/factories/finding.factory.ts](https://banes-lab.com/source/patterns/core/factories/finding.factory.ts.md) and before [core/factories/node.factory.ts](https://banes-lab.com/source/patterns/core/factories/node.factory.ts.md).

## Definitions

- `graphOf` (lexical_declaration, line 4, exported)
- `graph` (lexical_declaration, line 5, exported)

## Contained in

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

## Used by

- [core/pipelines/record.pipeline.ts](https://banes-lab.com/source/patterns/core/pipelines/record.pipeline.ts.md)
- [core/pipelines/snapshot.pipeline.ts](https://banes-lab.com/source/patterns/core/pipelines/snapshot.pipeline.ts.md)

## Linked from

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

## Source

```typescript
import { AnalysisGraph } from "#core/models/graph.model";
import type { Node } from "#types/graph.types";

export const graphOf = function graphOf(nodes: readonly Node[]): AnalysisGraph {
    const graph = new AnalysisGraph(nodes);
    graph.validate();
    return graph;
};
```
