-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing BFS #49
Comments
No bother at all! Thanks for trying it out, and sorry it's not a smooth experience yet. I have some ideas, and there's definitely some fixes to make on my end. Give me a day or two and I'll post a working solution that works on the #master branch. *Note in particular that indexing with GBVectors isn't working correctly right now. But I'll get it fixed! |
Thanks for your answer and don't worry! I see it's still in an early phase but definetely keep going because it's interesting to use this library! I'll wait for the fix and I'll try to implement other algorithms in the meanwhile |
I actually managed to solve the problem and to implement the algorithm:
EDIT: not using masks can degrade the performance of the algorithm from what I know but won't cause problems regarding the output of the algorithm |
I probably didn't cover some operation properly, which means it falls back to Julia, and Julia doesn't like nothing values in arrays. I spent today figuring out some memory issues, but I'll get the original working asap! |
Thanks for the update! PS=I looked at the code and the assign operation is not implemented, is there a work around for this at the moment? I need to compute an assign + mask operation |
|
Hey man thanks for the tip, i think I found another problem on MIN_FIRST semiring to compute parents inside the BFS. unfortunately this time I didn't managed to find a workaround
And my input (which is the same represented in the photo below) (source)
The min first operation in the semiring should return [nothing, 1, 0, 1, 0, 0, 0] but instead it returns [nothing, 1, 1, 1, 1, 1, 1]. The computation seems to be made on every row but instead should be done only in the selected rows. I just hope I'm not misunderstanding this operation in some way I can't figure it out right now. Thanks again for your patience |
Why would you want it to be
This is a full matrix of mostly zeros, not a sparse one. You can either do:
or
Or more idiomatically:
which is the cooordinate form. GraphBLAS treats zeros as actual numbers, which is not what SparseArrays does. I'm making a package that will behave like SparseArrays, but for graph algorithms you don't want this anyway. I'm going to write a BFS example this weekend, I'm just working on getting the next version out at the same time. So bear with me! :) |
Thanks man this tip solved my issue and i think this was the issue I had with the original post as well! I'm gonna try it tomorrow on the original algorithm i posted to check! I thought that 0 was equivalent to nothing and this was my problem! One more thing, citing your answer a couple of days ago regarding the assign command
in the single parents bfs implementation i used this command and it worked like a charm
basically it was for mapping index values (1, 2, 3, 4, 5 ecc...) to non-nothing f values to f (both index and f are vectors) Then i tried to implement the multi bfs parents algorithm, to compute more parents istances of different nodes at the same time. When i try to do the same assignment but with 2 matrices i get an error, both F and index are 3*7 matrices in this case with the same purposes of the line before (mapping from index to f non-nothing values)
example [1, 2, 3, 4, 5, 6, 7; 1, 2, 3, 4, 5, 6, 7; 1, 2, 3, 4, 5, 6, 7] and [1, nothing 1, nothing, nothing ... ; nothing, 1, nothign ... ; 1, nothing, nothing... ] result [1, nothing, 3, nothing, nothing ... ; nothing, 2, nothing, 1 ... ; 1, nothing, nothing ...]
|
That's a missing method on my part, it looks like index is transposed. I'll add it for the next release! |
Thanks again man! I'll try without transposing and see how it goes. I completed about 13/14 algorithms using the library till now and it was smooth, now I'll try to optimize them using the sparse keywords on the input matrices |
@samuel-esp do you mind making a PR to add your algorithms as examples? I can edit them, and figure out where I need to make changes to the API before the next release (hopefully in the next couple days)? |
Hey man, I can of course make a PR on your repo but not before September 10 because I'm actually on holiday and didn't bring my laptop with me, I don't know if I can make a PR from mobile but I don't think I can from the app. Actually you can check my examples from my public repo, so if you need to plan some corrections you can already see |
Ok I can still use them to figure out what I'm missing from the API. Then when you're back we can put them in as examples and polish. Enjoy your holiday! |
Hey man, I'm back from holiday and as promised I made the pull request. Feel free to review it on your free time, i could have forgotten some print statements inside the files so remove them just in case |
Hi guys,
I'm trying to implement the BFS-Level algorithm defined in this presentation but I'm facing several problems regarding any pairs semiring and nothing values. I'm quite new to the language as well but this is the implementation i tried
i tried the algorithm against this input
the Any_Pairs semirings should return 0, 1, 1, 1, 0, 0, 0 according to the matrix above but i'm getting [nothing, 1, 1, 1, 1, 1, 1]
I think I didn't understand quite well how to implement masking even if I succeded in implementing the Bellman Ford algorithm. Sorry again to bother you for this kind of issues
The text was updated successfully, but these errors were encountered: