Skip to content
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

Merged
merged 2 commits into from
Sep 17, 2020
Merged

Pagerank empty matrix #1342

merged 2 commits into from
Sep 17, 2020

Conversation

swilly22
Copy link
Contributor

Copy link
Contributor

@jeffreylovitz jeffreylovitz left a 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.

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);
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.


GrB_Info info;
GrB_Index n = 0; // Node count
GrB_Index nvals; // Number of entries in 'reduced'
Copy link
Contributor

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'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines +82 to +84
s = GraphContext_GetSchema(gc, label, SCHEMA_NODE);
// Unknown label, quickly return.
if(!s) return PROCEDURE_OK;
l = Graph_GetLabelMatrix(g, s->id);
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@jeffreylovitz jeffreylovitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change!

@swilly22 swilly22 merged commit db7475e into master Sep 17, 2020
@swilly22 swilly22 deleted the pagerank-empty-matrix branch September 17, 2020 13:04
pnxguide pushed a commit to CMU-SPEED/RedisGraph that referenced this pull request Mar 22, 2023
* do not call pagerank on empty matrix

* pagerank, optional arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants