(type: T)
| 500 | */ |
| 501 | export const make = |
| 502 | <T extends Kind>(type: T) => <N, E>(mutate?: (mutable: MutableGraph<N, E, T>) => undefined): Graph<N, E, T> => { |
| 503 | const graph: Mutable<GraphImpl<N, E, T>> = Object.create(ProtoGraph) |
| 504 | graph.type = type |
| 505 | graph.nodes = new Map() |
| 506 | graph.edges = new Map() |
| 507 | graph.adjacency = new Map() |
| 508 | graph.reverseAdjacency = new Map() |
| 509 | graph.nextNodeIndex = 0 |
| 510 | graph.nextEdgeIndex = 0 |
| 511 | graph.acyclic = Option.some(true) |
| 512 | |
| 513 | if (mutate === undefined) { |
| 514 | graph.mutable = false |
| 515 | return graph as unknown as Graph<N, E, T> |
| 516 | } |
| 517 | |
| 518 | graph.mutable = true |
| 519 | const mutable = Equal.byReferenceUnsafe(graph as unknown as MutableGraph<N, E, T>) |
| 520 | return mutateScoped(mutable, mutate) |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Creates a directed graph, optionally with initial mutations. |
no test coverage detected