Skip to content

Commit

Permalink
inline createEdge and createActiveEdge to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jul 30, 2023
1 parent 1509836 commit 14d7da7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
13 changes: 9 additions & 4 deletions src/lang/graph/connect.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
14 changes: 0 additions & 14 deletions src/lang/graph/createActiveEdge.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/lang/graph/createEdge.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lang/graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 14d7da7

Please sign in to comment.