dgleich / matlab-bgl

A graph library for Matlab based on the boost graph library
http://dgleich.github.com/matlab-bgl
110 stars 70 forks source link

Causing MATLAB shuts down #23

Closed cloudy-sfu closed 3 years ago

cloudy-sfu commented 3 years ago

The most simplified script to make this problem reappear:

x = zeros(2);
x = sparse(x);
c = clustering_coefficients(x);

It doesn't raise an error, instead, MATLAB shuts down.

dgleich commented 3 years ago

Does this work on a non-empty graph? If so, just add a line to clustering coefficients to return 0 for the empty graph.

cloudy-sfu commented 3 years ago

Yes, It works on a non-empty matrix. However, it’s weird that it shuts down, instead of raising an error. Why doesn’t it raise an error? Thank you for answering, and I'm curious about it.

dgleich commented 3 years ago

I had thought we had good empty checks in all the codes, but this one must have gotten missed...

Sorry about that, the easiest thing to do is just to add a check that the graph has any edges. I'm surprised this actually throws an error as it seems like the algorithm ought to work in such cases. I wonder if Mathworks changed howo they store these things.

Sorry again!

On Wed, Feb 17, 2021 at 12:31 PM cloudy-sfu notifications@github.com wrote:

Yes, It works on a non-empty matrix. However, it’s weird that it shuts down, instead of raising an error. Why doesn’t it raise an error? Thank you for answering, and I'm curious about it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dgleich/matlab-bgl/issues/23#issuecomment-780721699, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIJS7XPPNZLYYEQYCUUHLS7P4PBANCNFSM4XE6YSLA .

cloudy-sfu commented 3 years ago

The suggestion to fix this issue: https://github.com/dgleich/matlab-bgl/pull/24