Parcourir la source

NEW: full rework

Pavel Zhigalov il y a 4 semaines
Parent
commit
b4620517a5
33 fichiers modifiés avec 12 ajouts et 663 suppressions
  1. 2 1
      .gitignore
  2. 2 1
      eslint.config.js
  3. 4 3
      package.json
  4. 0 43
      src/graphs/abstract/DirectedEdge.ts
  5. 0 10
      src/graphs/abstract/DirectedGraph.ts
  6. 0 22
      src/graphs/abstract/Edge.ts
  7. 0 55
      src/graphs/abstract/Graph.ts
  8. 0 59
      src/graphs/abstract/GraphStore.ts
  9. 0 18
      src/graphs/abstract/Vertex.ts
  10. 0 63
      src/graphs/types/SimpleGraphStore.ts
  11. 0 11
      src/graphs/types/XDirectedEdge.ts
  12. 0 10
      src/graphs/types/XDirectedGraph.ts
  13. 0 10
      src/graphs/types/XVertex.ts
  14. 0 20
      src/index.ts
  15. 0 25
      src/io/abstract/JSONValibotParser.ts
  16. 0 11
      src/io/errors/BPMNIOError.ts
  17. 0 7
      src/io/interfaces/IJSONParser.ts
  18. 0 6
      src/io/interfaces/IJSONSerializer.ts
  19. 0 11
      src/io/interfaces/IParser.ts
  20. 0 12
      src/io/interfaces/ISerializer.ts
  21. 0 8
      src/optimizer/abstract/Optimizer.ts
  22. 0 16
      src/optimizer/abstract/OptimizerStep.ts
  23. 0 13
      src/optimizer/abstract/sugiyama-based/SugiyamaOptimizerStep.ts
  24. 0 10
      src/optimizer/errors/OptimizerError.ts
  25. 0 7
      src/optimizer/interfaces/IOptimizer.ts
  26. 0 4
      src/optimizer/interfaces/IOptimizerStep.ts
  27. 0 22
      src/optimizer/types/sugiyama-based/CrossingMinimizationStep.ts
  28. 0 63
      src/optimizer/types/sugiyama-based/CycleRemoverStep.ts
  29. 0 79
      src/optimizer/types/sugiyama-based/LayerAssignmentStep.ts
  30. 0 8
      src/optimizer/types/sugiyama-based/LinearOptimizationStep.ts
  31. 0 19
      src/optimizer/types/sugiyama-based/SiguyamaOptimizer.ts
  32. 0 0
      src/v1/errors/BPMNError.ts
  33. 4 16
      tsconfig.json

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 node_modules
 dist/**
-.idea/**
+.idea/**
+stuff/**

+ 2 - 1
eslint.config.js

@@ -20,6 +20,7 @@ export default defineConfig([
 			"@typescript-eslint/explicit-function-return-type": "error",
 			"indent": ["error", "tab"],
 			"no-mixed-spaces-and-tabs": ["error", "smart-tabs"]
-		}
+		},
+		ignores: ["dist/**/*"]
 	},
 ]);

+ 4 - 3
package.json

@@ -14,10 +14,11 @@
 	"type": "module",
 	"main": "index.js",
 	"scripts": {
-		"start": "npm run build && node dist/index.js",
 		"build": "tsc",
+		"start": "node dist/index.js",
+		"dev": "npm run build && node dist/index.js",
 		"debug": "npm run build && node --inspect dist/index.js",
-		"lint:fix": "eslint . --ext .ts --fix"
+		"lint:fix": "eslint . --ext .ts"
 	},
 	"devDependencies": {
 		"@eslint/eslintrc": "^3.3.4",
@@ -32,4 +33,4 @@
 	"dependencies": {
 		"valibot": "^1.2.0"
 	}
-}
+}

+ 0 - 43
src/graphs/abstract/DirectedEdge.ts

@@ -1,43 +0,0 @@
-import Vertex from "./Vertex.js";
-import Edge from "./Edge.js";
-
-/**
- * Абстрактный класс ориентированного ребра, соединяющего две вершины в строго определённом направлении
- * @template V Тип вершин, соединённых ребром
- * @abstract
- */
-export default abstract class DirectedEdge<V extends Vertex> extends Edge<V> {
-	protected constructor(id: number, source: V, target: V) {
-		super(id, source, target);
-	}
-
-	/**
-     * Вершина графа, из которой исходит ребро
-     */
-	get start() : V {
-		return this._v1;
-	}
-
-	/**
-     * Обновление исходящей вершины ребра
-     * @param start Новая исходящая вершина
-     */
-	set start(start: V) {
-		this._v1 = start;
-	}
-
-	/**
-     * Вершина, в которую направлено ребро
-     */
-	get target() : V {
-		return this._v2;
-	}
-
-	/**
-     * Обновление вершины, в которую направлено ребро
-     * @param target Новая вершина
-     */
-	set target(target: V) {
-		this._v2 = target;
-	}
-}

+ 0 - 10
src/graphs/abstract/DirectedGraph.ts

@@ -1,10 +0,0 @@
-import Graph from "./Graph.js";
-import Vertex from "./Vertex.js";
-import DirectedEdge from "./DirectedEdge.js";
-
-/**
- * Абстрактный класс, представляющий ориентированный граф
- * @template V Тип вершин графа
- * @template E Тип ориентированных рёбер графа
- */
-export default abstract class DirectedGraph<V extends Vertex, E extends DirectedEdge<V>> extends Graph<V, E> {}

+ 0 - 22
src/graphs/abstract/Edge.ts

@@ -1,22 +0,0 @@
-import Vertex from "./Vertex.js";
-
-/**
- * Абстрактный класс, описывающий ребро в графе
- * @template V Тип вершин, соединённых ребром
- * @abstract
- */
-export default abstract class Edge<V extends Vertex> {
-	private readonly _id: number;
-	protected _v1: V;
-	protected _v2: V;
-
-	protected constructor(id: number, v1: V, v2: V) {
-		this._id = id;
-		this._v1 = v1;
-		this._v2 = v2;
-	}
-
-	get id(): number {
-		return this._id;
-	}
-}

+ 0 - 55
src/graphs/abstract/Graph.ts

@@ -1,55 +0,0 @@
-import Vertex from "./Vertex.js";
-import Edge from "./Edge.js";
-import GraphStore from "./GraphStore.js";
-
-/**
- * Абстрактный класс, представляющий граф
- * @template V Тип вершин графа
- * @template E Тип рёбер графа
- * @abstract
- */
-export default abstract class Graph<V extends Vertex, E extends Edge<V>> {
-	private readonly _store: GraphStore<V, E>;
-
-	protected constructor(store: GraphStore<V, E>) {
-		this._store = store;
-	}
-
-	/**
-     * Список вершин графа
-     */
-	get vertices() : V[] {
-		return this._store.getAllVertices();
-	}
-
-	/**
-     * Список рёбер графа
-     */
-	get edges(): E[] {
-		return this._store.getAllEdges();
-	}
-
-	get store(): GraphStore<V, E> {
-		return this._store;
-	}
-
-	public getAdjacentVertices(vertex: V) : V[] {
-		return this._store.getAdjacentVertices(vertex.id);
-	}
-
-	public getIncidentEdges(vertexId: V["id"]): E[] {
-		return this._store.getIncidentEdges(vertexId);
-	}
-
-	public getVertexDegree(vertexId: V["id"]): number {
-		return this._store.getVertexDegree(vertexId);
-	}
-
-	public getInputs(vertexId: V["id"]): V[] {
-		return this._store.getInputs(vertexId);
-	}
-
-	public getOutputs(vertexId: V["id"]): V[] {
-		return this._store.getOutputs(vertexId);
-	}
-}

+ 0 - 59
src/graphs/abstract/GraphStore.ts

@@ -1,59 +0,0 @@
-import Vertex from "./Vertex.js";
-import Edge from "./Edge.js";
-
-/**
- * Класс, описывающий способ хранения графа
- */
-export default interface GraphStore<V extends Vertex, E extends Edge<V>> {
-    /**
-     * Получить вершину из графа по её уникальному идентификатору
-     * @param id Уникальный идентификатор вершины
-     */
-    getVertex(id: V["id"]): V|null;
-
-    /**
-     * Получение всех списков вершин в графе
-     */
-    getAllVertices(): V[];
-
-    /**
-     * Получить ребро из графа по её уникальному идентификатору
-     * @param id Уникальный идентификатор ребра
-     */
-    getEdge(id: E["id"]): E|null;
-
-    /**
-     * Получение всех рёбер в графе
-     */
-    getAllEdges(): E[];
-
-    /**
-     * Получить вершины, смежные с указанной
-     * @param id Уникальый идентификатор вершины, для которой необходимо найти смежные вершины
-     */
-    getAdjacentVertices(id: V["id"]): V[];
-
-    /**
-     * Получить список вершин графа, из которых можно попасть в данную вершину
-     * @param id Уникальный идентификатор вершины, для которой нужно посчитать количество "входящих" вершин
-     */
-    getInputs(id: V["id"]): V[];
-
-    /**
-     * Получить список вершин графа, в которые можно попасть из данной веришны
-     * @param id Уникальный идентификатор вершины, для которой нужно найти количество "исходящих" вершин
-     */
-    getOutputs(id: V["id"]): V[];
-
-    /**
-     * Получить ребра, инцидентные вершине
-     * @param id Уникальный идентификатор вершины, для которой нужно получить инцидентные ребра
-     */
-    getIncidentEdges(id: V["id"]): E[];
-
-    /**
-     * Получение степени вершины в графе
-     * @param id Уникальный идентификатор вершины, степень которой необходимо найти
-     */
-    getVertexDegree(id: V["id"]): number;
-}

+ 0 - 18
src/graphs/abstract/Vertex.ts

@@ -1,18 +0,0 @@
-/**
- * Абстрактный класс для вершин графов
- * @abstract
- */
-export default abstract class Vertex {
-	private readonly _id: number;
-
-	protected constructor(id: number) {
-		this._id = id;
-	}
-
-	/**
-     * Уникальный идентификатор вершины
-     */
-	get id() : number {
-		return this._id;
-	}
-}

+ 0 - 63
src/graphs/types/SimpleGraphStore.ts

@@ -1,63 +0,0 @@
-import GraphStore from "../abstract/GraphStore.js";
-import XVertex from "./XVertex.js";
-import XDirectedEdge from "./XDirectedEdge.js";
-import {inspect} from "node:util";
-
-export default class SimpleGraphStore implements GraphStore<XVertex, XDirectedEdge> {
-	private readonly _vertices: XVertex[];
-	private readonly _edges: XDirectedEdge[];
-
-	public constructor(vertices: XVertex[], edges: XDirectedEdge[]) {
-		this._vertices = vertices;
-		this._edges = edges;
-	}
-
-	getVertex(id: number): XVertex | null {
-		return this._vertices.find((vertex) => vertex.id == id) || null;
-	}
-
-	getAllVertices(): XVertex[] {
-		return this._vertices;
-	}
-
-	getEdge(id: number): XDirectedEdge | null {
-		return this._edges.find((edge) => edge.id == id) || null;
-	}
-
-	getAllEdges(): XDirectedEdge[] {
-		return this._edges;
-	}
-
-	getAdjacentVertices(id: number): XVertex[] {
-		return this.getIncidentEdges(id).map((edge) => edge.target);
-	}
-
-	getIncidentEdges(id: XVertex["id"]): XDirectedEdge[] {
-		const v = this.getVertex(id);
-		if(!v)
-			return [];
-
-		return this._edges.filter((edge) => edge.start.id == v.id || edge.target.id == v.id);
-	}
-
-	getVertexDegree(id: XVertex["id"]): number {
-		const incidentEdges = this.getIncidentEdges(id);
-		return incidentEdges.length;
-	}
-
-	getInputs(id: number): XVertex[] {
-		const v = this.getVertex(id);
-		if(!v)
-			return [];
-        
-		return this._edges.filter((e) => e.target.id == v.id).map((e) => e.start);
-	}
-
-	getOutputs(id: number): XVertex[] {
-		const v = this.getVertex(id);
-		if(!v)
-			return [];
-
-		return this._edges.filter((e) => e.start.id == v.id).map((e) => e.target);
-	}
-}

+ 0 - 11
src/graphs/types/XDirectedEdge.ts

@@ -1,11 +0,0 @@
-import DirectedEdge from "../abstract/DirectedEdge.js";
-import XVertex from "./XVertex.js";
-
-/**
- * Стандартная реализация направленного ребра графа, соединяющего две вершины типа {@link XVertex}
- */
-export default class XDirectedEdge extends DirectedEdge<XVertex> {
-	public constructor(id: number, start: XVertex, target: XVertex) {
-		super(id, start, target);
-	}
-}

+ 0 - 10
src/graphs/types/XDirectedGraph.ts

@@ -1,10 +0,0 @@
-import Graph from "../abstract/Graph.js";
-import XDirectedEdge from "./XDirectedEdge.js";
-import XVertex from "./XVertex.js";
-import GraphStore from "../abstract/GraphStore.js";
-
-export default class XDirectedGraph extends Graph<XVertex, XDirectedEdge> {
-	public constructor(store: GraphStore<XVertex, XDirectedEdge>) {
-		super(store);
-	}
-}

+ 0 - 10
src/graphs/types/XVertex.ts

@@ -1,10 +0,0 @@
-import Vertex from "../abstract/Vertex.js";
-
-/**
- * Стандартная реализация вершины графа
- */
-export default class XVertex extends Vertex {
-	public constructor(id: number) {
-		super(id);
-	}
-}

+ 0 - 20
src/index.ts

@@ -1,20 +0,0 @@
-import XDirectedEdge from "./graphs/types/XDirectedEdge.js";
-import XVertex from "./graphs/types/XVertex.js";
-import XDirectedGraph from "./graphs/types/XDirectedGraph.js";
-import SimpleGraphStore from "./graphs/types/SimpleGraphStore.js";
-import SiguyamaOptimizer from "./optimizer/types/sugiyama-based/SiguyamaOptimizer.js";
-import CycleRemoverStep from "./optimizer/types/sugiyama-based/CycleRemoverStep.js";
-import LinearOptimizationStep from "./optimizer/types/sugiyama-based/LinearOptimizationStep.js";
-import LayerAssignmentStep from "./optimizer/types/sugiyama-based/LayerAssignmentStep.js";
-
-const v = [new XVertex(1), new XVertex(2), new XVertex(3), new XVertex(4)]
-const e = [new XDirectedEdge(1, v[0]!, v[1]!), new XDirectedEdge(2, v[1]!, v[2]!), new XDirectedEdge(3, v[0]!, v[2]!), new XDirectedEdge(4, v[0]!, v[3]!)]
-const g = new XDirectedGraph(new SimpleGraphStore(v, e));
-
-const cycleRemover = new CycleRemoverStep();
-cycleRemover.setNext(new LayerAssignmentStep()).setNext(new LinearOptimizationStep());
-
-new SiguyamaOptimizer(cycleRemover)
-	.optimize(g)
-	.then((g) => console.log(`Result: ${JSON.stringify(g)}`))
-	.catch((err) => console.error(err));

+ 0 - 25
src/io/abstract/JSONValibotParser.ts

@@ -1,25 +0,0 @@
-import IJSONParser from "../interfaces/IJSONParser.js";
-import {BaseIssue, BaseSchema} from "valibot";
-
-/**
- * Обший класс для всех парсеров, использующих библиотеку {@link https://valibot.dev/|Valibot} для парсинга JSON-данных в классы и объекты
- * @template TSchema Тип схемы, применяемой для парсинга объекта
- * @template Out Тип данных, получающихся после парсинга объекта
- */
-export default abstract class JSONValibotParser<TSchema extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, Out> implements IJSONParser<Out> {
-	/**
-     * Схема для валидации JSON-данных
-     * @protected
-     */
-	protected readonly _schema: TSchema;
-
-	protected constructor(schema: TSchema) {
-		this._schema = schema;
-	}
-
-	/**
-     * Парсинг сырых JSON-данных с помощью {@link _schema|схемы} и возврат обычного объекта типа {@link Out}
-     * @param input JSON-данных, парсинг которых необходимо провести
-     */
-	public abstract parse(input: string): Out;
-}

+ 0 - 11
src/io/errors/BPMNIOError.ts

@@ -1,11 +0,0 @@
-import BPMNError from "../../core/errors/BPMNError.js";
-
-/**
- * Ошибка, которая возникает при выполнении операций ввода-вывода с BPMN моделями, таких как чтение или запись файлов.
- */
-export default class BPMNIOError extends BPMNError {
-	public constructor(message?: string) {
-		super(`Error during BPMN I/O operation: ${message ?? "Unknown error"}`);
-		this.name = this.constructor.name;
-	}
-}

+ 0 - 7
src/io/interfaces/IJSONParser.ts

@@ -1,7 +0,0 @@
-import IParser from "./IParser.js";
-
-/**
- * Интерфейс парсера, преобразующего строку формата JSON в объект Javascript-класса
- */
-// eslint-disable-next-line @typescript-eslint/no-empty-object-type
-export default interface IJSONParser<Out> extends IParser<string, Out> {}

+ 0 - 6
src/io/interfaces/IJSONSerializer.ts

@@ -1,6 +0,0 @@
-import ISerializer from "./ISerializer.js";
-
-/**
- * Интерфейс для сериализации данных в JSON-формат
- */
-export default interface IJSONSerializer<TData> extends ISerializer<TData, string> {}

+ 0 - 11
src/io/interfaces/IParser.ts

@@ -1,11 +0,0 @@
-/**
- * Интерфейс для парсера, который преобразует входные данные одного типа в выходные данные другого типа.
- */
-export default interface IParser<In, Out> {
-	/**
-	 * Парсинг входных данных и преобразование их в выходные данные
-	 * @param input Входные данные для парсинга
-	 * @returns Результат парсинга в виде выходных данных
-	 */
-	parse(input: In): Out;
-}

+ 0 - 12
src/io/interfaces/ISerializer.ts

@@ -1,12 +0,0 @@
-/**
- * Интерфейс для сериализации объектов javascript типа {@link TData} в представление типа {@link TOut}
- * @template TData Исходное представление данных
- * @template TOut Тип данных, в который будет произведена сериализация
- */
-export default interface ISerializer<TData, TOut> {
-    /**
-     * Сериализация объекта типа {@link TData} в тип {@link TOut}
-     * @param data Данные, которые необходимо сериализовать
-     */
-    serialize(data: TData): TOut;
-}

+ 0 - 8
src/optimizer/abstract/Optimizer.ts

@@ -1,8 +0,0 @@
-import IOptimizer from "../interfaces/IOptimizer.js";
-import Vertex from "../../graphs/abstract/Vertex.js";
-import Edge from "../../graphs/abstract/Edge.js";
-import Graph from "../../graphs/abstract/Graph.js";
-
-export default abstract class Optimizer<V extends Vertex, E extends Edge<V>, G extends Graph<V, E>> implements IOptimizer<V, E, G> {
-    public abstract optimize(source: G): Promise<G>;
-}

+ 0 - 16
src/optimizer/abstract/OptimizerStep.ts

@@ -1,16 +0,0 @@
-import IOptimizerStep from "../interfaces/IOptimizerStep.js";
-
-export default abstract class OptimizerStep<Context> implements IOptimizerStep<Context> {
-	private _nextStep: IOptimizerStep<Context> | undefined;
-
-	public setNext(step: OptimizerStep<Context>): OptimizerStep<Context> {
-		this._nextStep = step;
-		return step;
-	}
-
-	public process(context: Context): Context {
-		if(this._nextStep)
-			return this._nextStep.process(context);
-		return context;
-	}
-}

+ 0 - 13
src/optimizer/abstract/sugiyama-based/SugiyamaOptimizerStep.ts

@@ -1,13 +0,0 @@
-import XDirectedGraph from "../../../graphs/types/XDirectedGraph.js";
-import OptimizerStep from "../OptimizerStep.js";
-import XDirectedEdge from "../../../graphs/types/XDirectedEdge.js";
-import XVertex from "../../../graphs/types/XVertex.js";
-
-export type Context = {
-    graph: XDirectedGraph,
-    acyclicGraph?: XDirectedGraph,
-    reversedEdges?: XDirectedEdge[],
-    layers?: XVertex[][]
-}
-
-export default abstract class SugiyamaOptimizerStep extends OptimizerStep<Context> {}

+ 0 - 10
src/optimizer/errors/OptimizerError.ts

@@ -1,10 +0,0 @@
-import BPMNError from "../../core/errors/BPMNError.js";
-
-/**
- * Ошибка, возникшая в результате работы процессов оптимизации
- */
-export default class OptimizerError extends BPMNError {
-	public constructor(message: string) {
-		super(`Error during optimization processes: ${message}`);
-	}
-}

+ 0 - 7
src/optimizer/interfaces/IOptimizer.ts

@@ -1,7 +0,0 @@
-import Graph from "../../graphs/abstract/Graph.js";
-import Vertex from "../../graphs/abstract/Vertex.js";
-import Edge from "../../graphs/abstract/Edge.js";
-
-export default interface IOptimizer<V extends Vertex, E extends Edge<V>, G extends Graph<V, E>> {
-    optimize(source: G): Promise<G>
-}

+ 0 - 4
src/optimizer/interfaces/IOptimizerStep.ts

@@ -1,4 +0,0 @@
-export default interface IOptimizerStep<Context> {
-    process(input: Context): Context;
-    setNext(step: IOptimizerStep<Context>): IOptimizerStep<Context>;
-}

+ 0 - 22
src/optimizer/types/sugiyama-based/CrossingMinimizationStep.ts

@@ -1,22 +0,0 @@
-import SugiyamaOptimizerStep, {Context} from "../../abstract/sugiyama-based/SugiyamaOptimizerStep.js";
-import OptimizerError from "../../errors/OptimizerError.js";
-import XDirectedGraph from "../../../graphs/types/XDirectedGraph.js";
-import XVertex from "../../../graphs/types/XVertex.js";
-
-export default class CrossingMinimizationStep extends SugiyamaOptimizerStep {
-	process(context: Context): Context {
-		const { graph, layers } = context;
-
-		if(!layers)
-			throw new OptimizerError("Layers with vertices was not found")
-
-		this.minimizeCrosses(graph, layers);
-
-		return super.process(context);
-	}
-
-	protected minimizeCrosses(graph: XDirectedGraph, layers: XVertex[][]): XVertex[][] {
-		// TODO
-		return []
-	}
-}

+ 0 - 63
src/optimizer/types/sugiyama-based/CycleRemoverStep.ts

@@ -1,63 +0,0 @@
-import SugiyamaOptimizerStep, {Context} from "../../abstract/sugiyama-based/SugiyamaOptimizerStep.js";
-import XDirectedGraph from "../../../graphs/types/XDirectedGraph.js";
-import XDirectedEdge from "../../../graphs/types/XDirectedEdge.js";
-import XVertex from "../../../graphs/types/XVertex.js";
-import SimpleGraphStore from "../../../graphs/types/SimpleGraphStore.js";
-
-type CycleRemoverStepOutput = {
-    reversedEdges: NonNullable<Context["reversedEdges"]>,
-    acyclicGraph: NonNullable<Context["acyclicGraph"]>
-};
-
-export default class CycleRemoverStep extends SugiyamaOptimizerStep {
-	public process(context: Context): Context {
-		const { graph } = context;
-        
-		const { reversedEdges, acyclicGraph } = this.cycleRemover(graph);
-
-		context.acyclicGraph = acyclicGraph;
-		context.reversedEdges = reversedEdges;
-
-		return super.process(context);
-	}
-
-	protected cycleRemover(graph: XDirectedGraph) : CycleRemoverStepOutput {
-		return this.dfs(graph);
-	}
-
-	private dfs(graph: XDirectedGraph) : CycleRemoverStepOutput {
-		const stack: { incidentEdge?: XDirectedEdge, vertex: XVertex }[] = [];
-		const visited = new Set<XVertex>();
-		const reversedEdges = new Set<XDirectedEdge>();
-
-		const startVertex = graph.vertices[Math.floor(Math.random() * graph.vertices.length)]!;
-
-		stack.push({ vertex: startVertex });
-
-		while(stack.length > 0) {
-			const current = stack.pop();
-
-			if(!current)
-				continue;
-
-			const currVertex = current.vertex;
-
-			if(current.incidentEdge && visited.has(currVertex)) {
-				reversedEdges.add(current.incidentEdge)
-				continue;
-			}
-
-			visited.add(currVertex);
-
-			for(const edge of graph.edges.filter((edge) => edge.start.id == currVertex.id))
-				stack.push({ incidentEdge: edge, vertex: edge.target });
-		}
-
-		const acyclicGraph = new XDirectedGraph(new SimpleGraphStore(
-			graph.vertices,
-			graph.edges.map((edge) => reversedEdges.has(edge) ? new XDirectedEdge(edge.id, edge.target, edge.start) : edge)
-		));
-
-		return { acyclicGraph: acyclicGraph, reversedEdges: Array.from(reversedEdges) }
-	}
-}

+ 0 - 79
src/optimizer/types/sugiyama-based/LayerAssignmentStep.ts

@@ -1,79 +0,0 @@
-import SugiyamaOptimizerStep, {Context} from "../../abstract/sugiyama-based/SugiyamaOptimizerStep.js";
-import OptimizerError from "../../errors/OptimizerError.js";
-import XDirectedGraph from "../../../graphs/types/XDirectedGraph.js";
-import XVertex from "../../../graphs/types/XVertex.js";
-
-export default class LayerAssignmentStep extends SugiyamaOptimizerStep {
-	process(context: Context): Context {
-		const { acyclicGraph } = context;
-
-		if(!acyclicGraph)
-			throw new OptimizerError("Directed acyclic graph is null or undefined");
-
-		context.layers = this.assignLayers(acyclicGraph);
-
-		console.log(context.layers)
-
-		return super.process(context);
-	}
-
-	protected assignLayers(graph: XDirectedGraph): XVertex[][] {
-		const topologicalOrder = this.topologicalSort(graph);
-
-		const layers = new Map<XVertex, number>()
-
-		for(const vertex of topologicalOrder) {
-			const inputs = graph.getInputs(vertex.id);
-
-			if(inputs.length == 0) {
-				layers.set(vertex, 0);
-			} else {
-				const maxInputsLayer = Math.max(
-					...inputs.map((input) => layers.get(input) ?? 0)
-				);
-				layers.set(vertex, maxInputsLayer + 1);
-			}
-		}
-
-		const maxLayer = Math.max(...layers.values());
-		const result: XVertex[][] = Array.from({ length: maxLayer + 1 }, () => []);
-
-		for(const [vertex, layer] of layers)
-			result[layer]!.push(vertex);
-
-		return result;
-	}
-
-	private topologicalSort(graph: XDirectedGraph): XVertex[] {
-		const degreeMap = new Map<XVertex, number>();
-
-		for(const vertex of graph.vertices)
-			degreeMap.set(vertex, graph.getInputs(vertex.id).length);
-
-		const stack: XVertex[] = [];
-
-		for(const [vertex, degree] of degreeMap)
-			if(degree == 0)
-				stack.push(vertex);
-
-		const result: XVertex[] = [];
-
-		while(stack.length > 0) {
-			const curr = stack.shift()!;
-			result.push(curr);
-
-			for(const neighbour of graph.getOutputs(curr.id)) {
-				const newDegree = (degreeMap.get(neighbour) ?? 0) - 1;
-				degreeMap.set(neighbour, newDegree);
-
-				if(newDegree == 0)
-					stack.push(neighbour);
-			}
-		}
-
-		if(result.length != graph.vertices.length)
-			throw new OptimizerError("Cycle is detected..")
-
-		return result;
-	}
-}

+ 0 - 8
src/optimizer/types/sugiyama-based/LinearOptimizationStep.ts

@@ -1,8 +0,0 @@
-import SugiyamaOptimizerStep, {Context} from "../../abstract/sugiyama-based/SugiyamaOptimizerStep.js";
-
-export default class LinearOptimizationStep extends SugiyamaOptimizerStep {
-	public process(context: Context): Context {
-		//TODO
-		return super.process(context);
-	}
-}

+ 0 - 19
src/optimizer/types/sugiyama-based/SiguyamaOptimizer.ts

@@ -1,19 +0,0 @@
-import Optimizer from "../../abstract/Optimizer.js";
-import XVertex from "../../../graphs/types/XVertex.js";
-import XDirectedEdge from "../../../graphs/types/XDirectedEdge.js";
-import XDirectedGraph from "../../../graphs/types/XDirectedGraph.js";
-import SugiyamaOptimizerStep from "../../abstract/sugiyama-based/SugiyamaOptimizerStep.js";
-
-export default class SiguyamaOptimizer extends Optimizer<XVertex, XDirectedEdge, XDirectedGraph> {
-	private readonly _chain: SugiyamaOptimizerStep;
-
-	public constructor(chain: SugiyamaOptimizerStep) {
-		super();
-		this._chain = chain;
-	}
-
-	public async optimize(source: XDirectedGraph): Promise<XDirectedGraph> {
-		this._chain.process({ graph: source });
-		return source;
-	}
-}

+ 0 - 0
src/core/errors/BPMNError.ts → src/v1/errors/BPMNError.ts


+ 4 - 16
tsconfig.json

@@ -1,11 +1,7 @@
 {
-	// Visit https://aka.ms/tsconfig to read more about this file
 	"compilerOptions": {
-		// File Layout
 		"rootDir": "./src",
 		"outDir": "./dist",
-		// Environment Settings
-		// See also https://aka.ms/tsconfig/module
 		"module": "nodenext",
         "moduleResolution": "nodenext",
         "esModuleInterop": true,
@@ -13,27 +9,19 @@
 		"types": [
 			"node"
 		],
-		// Other Outputs
 		"sourceMap": true,
 		"declaration": true,
 		"declarationMap": true,
-		// Stricter Typechecking Options
 		"noUncheckedIndexedAccess": true,
 		"exactOptionalPropertyTypes": true,
-		// Style Options
-		// "noImplicitReturns": true,
-		// "noImplicitOverride": true,
-		// "noUnusedLocals": true,
-		// "noUnusedParameters": true,
-		// "noFallthroughCasesInSwitch": true,
-		// "noPropertyAccessFromIndexSignature": true,
-		// Recommended Options
 		"strict": true,
 		"jsx": "react-jsx",
 		"verbatimModuleSyntax": false,
 		"isolatedModules": true,
 		"noUncheckedSideEffectImports": true,
 		"moduleDetection": "force",
-		"skipLibCheck": true,
-	}
+		"skipLibCheck": true
+	},
+	"include": ["./src/**/*"],
+	"exclude": ["node_modules", "dist"]
 }