Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dslmeinte
Last active July 17, 2017 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dslmeinte/d8f0777201226799eb97e07848efcbda to your computer and use it in GitHub Desktop.
Save dslmeinte/d8f0777201226799eb97e07848efcbda to your computer and use it in GitHub Desktop.
Projection of a directed graph (pseudo-TS-code)
export enum Style {
none, selected, highlighted
}
export abstract class Element {
abstract style(): Style;
}
export class ProjectedVertex extends Element {
id: number;
position: Point;
style() { /* ... */ }
}
export class Edge extends Element {
fromVertex: ProjectedVertex;
toVertex: ProjectedVertex;
style() { /* ... */ }
}
export type Projection = Element[];
export function projectStore(store: Store): Projection {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment