public void AddConnection(INode fromNode, INode toNode, int distance) { if (nodes.ContainsKey(fromNode.Name) == false) { throw new NodeNotFoundException($"Could not find node {fromNode?.Name}"); } if (nodes.ContainsKey(toNode.Name) == false) { throw new NodeNotFoundException($"Could not find node {toNode?.Name}"); } fromNode.AddConnection(nodes[toNode.Name], distance); }