| 1819 | * @since 3.18.0 |
| 1820 | */ |
| 1821 | export const updateEdge = <N, E, T extends Kind = "directed">( |
| 1822 | mutable: MutableGraph<N, E, T>, |
| 1823 | edgeIndex: EdgeIndex, |
| 1824 | f: (data: E) => E |
| 1825 | ): void => { |
| 1826 | assertMutable(mutable) |
| 1827 | const impl = graphImpl(mutable) |
| 1828 | |
| 1829 | if (!impl.edges.has(edgeIndex)) { |
| 1830 | return |
| 1831 | } |
| 1832 | |
| 1833 | const currentEdge = impl.edges.get(edgeIndex)! |
| 1834 | const newData = f(currentEdge.data) |
| 1835 | impl.edges.set(edgeIndex, new Edge({ ...currentEdge, data: newData })) |
| 1836 | } |
| 1837 | |
| 1838 | /** |
| 1839 | * Transforms every node's data in a mutable graph in place using the provided |