public void AddEdge(string from, string to, int weight) { Node fromNode = _nodes[from]; if (fromNode == null) { throw new Exception(); } Node toNode = _nodes[to]; if (toNode == null) { throw new Exception(); } fromNode.AddEdge(toNode, weight); toNode.AddEdge(fromNode, weight); }