// Add neighbours and make sure that we just add the reference if the node already exists in the graph. private void AddNeighbours(SceneNode node, string[] neighbours) { for (int i = 0; i < neighbours.Length; i++) { string neighbourName = neighbours[i]; SceneNode neighbour = GetNode(neighbourName); if (neighbour == null) { // Create new one neighbour = new SceneNode(neighbourName); _nodes.Add(neighbour); } node.AddNeighbour(neighbour); } }