snap-stanford / snap

Stanford Network Analysis Platform (SNAP) is a general purpose network analysis and graph mining library.
Other
2.16k stars 795 forks source link

fix a bug in cncom.h & speed up AddVMerged(const TVec&) #224

Open zhaolu996 opened 3 years ago

zhaolu996 commented 3 years ago

Hi! I have refined two functions : IsNIdIn(const TInt&) and AddVMerged(TVec&).

The value member NIdV of the class TCnCom is unsorted, so the original IsNIdIn(const TInt&) worked incorrectly. I fixed it simply by replacing the binary search with the forwarding search. I add a few lines of test codes to show the incorrectness/correctness of the original/refined implementation.

Another issue I discovered when using snap is that the AddVMerged(TVec&) was slower than I expected. And my contributions to this issue are :

I would hope these two simple refinements would be helpful.

Zhao