mfe- / DataStructures.Algorithms

DataStructures and algorithms
Other
53 stars 10 forks source link

IVertex parameter is null in OnBreadthFirstSearchCommand(IVertex vertex) method and Kruskal doesn't work #17

Closed appcompat1 closed 2 years ago

appcompat1 commented 2 years ago

Repro steps:

  1. Clone the code from main branch and open with VS2022.

  2. Press F5 to launch the DataStructures.UI.Demo project.

  3. Select node 3 and right-click to choose BreadthFirstSearch option. image

  4. It will throw Object reference not set to an instance of an object at DataStructures.UI.Demo\Window1ViewModel.cs:line 116

Findings: After checking the line 116, we found the vertex object is null.

Another issue:

  1. Press F5 to launch the DataStructures.UI.Demo project.
  2. Select node 3 and right-click to choose Kruskal option.

Excepted Result: The screen should show this result. image

Actual Result: The screen doesn't do any changes. It keeps in this: image

mfe- commented 2 years ago

Thanks @appcompat1 for reporting! The null reference exception occurs, when no vertex is selected. I added an additional null check.

The graph should now update when using Kruskal see PR #19 .

Let me know if its working for you and feel free to reopen.