小于 1 分钟
Home > @hz-9/algorithm > Graph > addEdge
Graph.addEdge() method
Add an edge to the graph.
添加边到图中。
Signature:
addEdge(fromVertex: T | Vertice<T>, toVertex: T | Vertice<T>, weight?: number): void;Parameters
Parameter | Type | Description |
|---|---|---|
fromVertex | T | Vertice<T> | The first vertex of the edge. (If the graph is directed, the order of vertices matters.) |
toVertex | T | Vertice<T> | The second vertex of the edge. |
weight | number | (Optional) The weight of the edge. Default value is 1. |
Returns:
void