0.2.3 • Published 3 years ago

entity-graph v0.2.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

entity-graph

Usage

import { Graph, IVertex, IEdge } from 'entity-graph';

interface Person extends IVertex<'person'> {
  readonly name: string;
  readonly age: number;
}

interface Place extends IVertex<'place'> {
  readonly name: string;
  readonly population: number;
}

interface From extends IEdge<Person, Place, 'from'> {
  isKnown: boolean;
}

type Vertices = Person | Place;
type Edges = From;

const g = new Graph<Vertices, Edges>();

g.setVertex('1', 'place', { name: 'NYC', population: 1 });
g.setVertex('2', 'place', { name: 'LA', population: 2 });
g.setVertex('3', 'person', { name: 'Alice', age: 3 });
g.setEdge('3', '1', 'from', { isKnown: true });
0.2.1

3 years ago

0.2.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago