addEdge

abstract fun addEdge(node1: T, node2: T)

Adds an unweighted edge between two nodes in the graph, and creates the nodes if they don't exist.

Parameters

node1

The starting node of the edge.

node2

The ending node of the edge.


abstract fun addEdge(node1: T, node2: T, weight: Double)

Adds an edge between two nodes in the graph, and creates the nodes if they don't exist.

Parameters

node1

The starting node of the edge.

node2

The ending node of the edge.

weight

The weight of the edge, for example used to calculate distances with dijkstra.


fun addEdge(node1: T, node2: T, weight: Int)

Overloaded function that calls addEdge with weight converted to a double.