-
Notifications
You must be signed in to change notification settings - Fork 230
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
Pagerank empty matrix #1342
Pagerank empty matrix #1342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this PR, and think that the optional arguments for Pagerank are a clear improvement.
I feel like generally we adhere to the philosophy of keeping variables in the smallest scope possible and logically grouping declarations/assignments with their first usage, and find it strange that this file deviates so much from those practices. It's not a particularly important issue, though.
src/procedures/proc_pagerank.c
Outdated
GrB_Descriptor_new(&desc); | ||
GrB_Descriptor_set(desc, GrB_INP0, GrB_TRAN); | ||
info = GrB_transpose(reduced, GrB_NULL, GrB_NULL, r, desc); | ||
ASSERT(info == GrB_SUCCESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tab?
const int itermax = 100; // max iterations | ||
|
||
GrB_Info info; | ||
GrB_Index n = 0; // Node count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initialization doesn't seem useful to me, as we'll always choose a real value for n
at 101.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's important to set n
to 0 here as it is later line 11 being used to initialise the PagerankContext
n
notes the number of results returned from the actual PageRank algorithm.
src/procedures/proc_pagerank.c
Outdated
|
||
GrB_Info info; | ||
GrB_Index n = 0; // Node count | ||
GrB_Index nvals; // Number of entries in 'reduced' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Number of entries in 'r'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/procedures/proc_pagerank.c
Outdated
GrB_Matrix l = NULL; // Label matrix | ||
GrB_Matrix r = NULL; // Relation matrix | ||
GrB_Index *mapping = NULL; // Mapping, array for returning row indices of tuples | ||
GrB_Matrix reduced = GrB_NULL; // Relation matrix reduced to only 'l' rows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduced
could be declared inside the if
condition at 110.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
pdata->mapping = mapping; | ||
pdata->ranking = ranking; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will always be assigned at 165-166.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if we quickly return at lines 83 and 91
s = GraphContext_GetSchema(gc, label, SCHEMA_NODE); | ||
// Unknown label, quickly return. | ||
if(!s) return PROCEDURE_OK; | ||
l = Graph_GetLabelMatrix(g, s->id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it makes more sense to perform this work in the if(label)
condition at 114.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this notion of a "barrier", from this point onward we have both a label and relation matrices, which the next scope relies on.
const double tol = 1e-4; // tolerance | ||
const int itermax = 100; // max iterations | ||
|
||
GrB_Info info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler warning in non-debug builds:
warning: variable ‘info’ set but not used
We should probably add an UNUSED
macro to avoid these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
5f56322
to
89eed6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change!
* do not call pagerank on empty matrix * pagerank, optional arguments
#1340