diff --git a/src/lang/graph/connect.ts b/src/lang/graph/connect.ts index 794da0ec..be99e64c 100644 --- a/src/lang/graph/connect.ts +++ b/src/lang/graph/connect.ts @@ -1,13 +1,18 @@ -import { Net, Port, createEdge } from "." +import { Net, Port } from "." import { lookupRuleByPorts } from "../mod/lookupRuleByPorts" -import { createActiveEdge } from "./createActiveEdge" export function connect(net: Net, start: Port, end: Port): void { const rule = lookupRuleByPorts(net.mod, start, end) if (rule !== undefined) { - net.activeEdges.push(createActiveEdge(start, end, rule)) + const edge = { start, end, rule } + start.connection = { edge, port: end } + end.connection = { edge, port: start } + net.activeEdges.push(edge) } else { - net.edges.push(createEdge(start, end)) + const edge = { start, end } + start.connection = { edge, port: end } + end.connection = { edge, port: start } + net.edges.push(edge) } } diff --git a/src/lang/graph/createActiveEdge.ts b/src/lang/graph/createActiveEdge.ts deleted file mode 100644 index 2c1b2283..00000000 --- a/src/lang/graph/createActiveEdge.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ActiveEdge, Port } from "../graph" -import { Rule } from "../rule" - -export function createActiveEdge( - start: Port, - end: Port, - rule: Rule, -): ActiveEdge { - return { - start, - end, - rule, - } -} diff --git a/src/lang/graph/createEdge.ts b/src/lang/graph/createEdge.ts deleted file mode 100644 index d4ee80fc..00000000 --- a/src/lang/graph/createEdge.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Edge, Port } from "../graph" - -export function createEdge(start: Port, end: Port): Edge { - const edge = { start, end } - - start.connection = { edge, port: end } - end.connection = { edge, port: start } - - return edge -} diff --git a/src/lang/graph/index.ts b/src/lang/graph/index.ts index 61084bec..ea18628f 100644 --- a/src/lang/graph/index.ts +++ b/src/lang/graph/index.ts @@ -3,6 +3,5 @@ export * from "./Edge" export * from "./Net" export * from "./Node" export * from "./Port" -export * from "./createEdge" export * from "./createNode" export * from "./createPort"