MCPcopy Create free account
hub / github.com/Effect-TS/effect / graphEdgeKeys

Function graphEdgeKeys

packages/effect/test/Graph.test.ts:64–72  ·  view source on GitHub ↗
(graph: Graph.Graph<SetNode, E, T>)

Source from the content-addressed store, hash-verified

62 new Map(Array.from(graph, ([, node]) => [node.id, node.label]))
63
64const graphEdgeKeys = <E, T extends Graph.Kind>(graph: Graph.Graph<SetNode, E, T>) => {
65 const nodeIds = new Map(Array.from(graph, ([index, node]) => [index, node.id]))
66 return new Set(
67 Array.from(Graph.edges(graph), ([, edge]) =>
68 graph.type === "directed"
69 ? `${nodeIds.get(edge.source)}->${nodeIds.get(edge.target)}`
70 : `${nodeIds.get(edge.source)}--${nodeIds.get(edge.target)}`)
71 )
72}
73
74const graphEdgeData = <E, T extends Graph.Kind>(graph: Graph.Graph<SetNode, E, T>) => {
75 const nodeIds = new Map(Array.from(graph, ([index, node]) => [index, node.id]))

Callers 1

Graph.test.tsFile · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected