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

fix(analytical): make clustering support undirected graph #3715

Merged
merged 7 commits into from
Apr 17, 2024

Conversation

acezen
Copy link
Collaborator

@acezen acezen commented Apr 16, 2024

What do these changes do?

see #3711

Related issue number

Fixes #3711

@acezen acezen requested a review from doudoubobo April 16, 2024 10:41
@acezen acezen changed the title fix(analytical): clustering support undirected graph fix(analytical): make clustering support undirected graph Apr 16, 2024
@acezen acezen force-pushed the 3711-support-undirected-clustering branch from 8ace7e6 to fb03381 Compare April 17, 2024 02:01
@acezen
Copy link
Collaborator Author

acezen commented Apr 17, 2024

hi, @doudoubobo, I have a question about the computational formula of clustering:

@acezen acezen force-pushed the 3711-support-undirected-clustering branch from fb03381 to cd1240c Compare April 17, 2024 02:18
@doudoubobo
Copy link
Collaborator

hi, @doudoubobo, I have a question about the computational formula of clustering:

Q: why our formula is [T(v) / deg(v)*(deg(v)-1]?
A: In the implement method of triangle counting, I remember the real triangle counting number for undirected graph is 2.0 * T(v) and 1.0 * T(v) for directed graph (see https://en.wikipedia.org/wiki/Clustering_coefficient)

Q: what's the meaning and use of rec_degree?
A: See https://en.wikipedia.org/wiki/Clustering_coefficient, the k_i is defined as the neighbor number of a vertex. For a directed graph, if both src-->dst and dst-->src edges exist, the degree of src is 2 but the k_i is 1. rec_degree is used to handle such situation.

doudoubobo
doudoubobo previously approved these changes Apr 17, 2024
@acezen acezen force-pushed the 3711-support-undirected-clustering branch from cd1240c to bade58b Compare April 17, 2024 02:54
@acezen acezen requested a review from siyuan0322 April 17, 2024 02:55
@acezen
Copy link
Collaborator Author

acezen commented Apr 17, 2024

hi, @doudoubobo, since GraphScope only allow one MessageStrategy in one application:

static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongEdgeToOuterVertex;

for undirected graph, the strategy should be kAlongOutgoingEdgeToOuterVertex and use SendMsgThroughOEdges to send message like triangle:

messages.SendMsgThroughOEdges<fragment_t, int>(frag, v,
ctx.global_degree[v], tid);
});

But for the reason above, I use SendMsgThroughEdges for both directed graph and undirected graph, and the test case is ok to pass.

messages.SendMsgThroughEdges<fragment_t, int>(
frag, v, ctx.global_degree[v], tid);

Can you help me double check that SendMsgThroughEdges is ok for directed graph and undirected graph in the message passing between fragments? I don't want to bring another potential bug with the changes.

@doudoubobo
Copy link
Collaborator

hi, @doudoubobo, since GraphScope only allow one MessageStrategy in one application:

static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongEdgeToOuterVertex;

for undirected graph, the strategy should be kAlongOutgoingEdgeToOuterVertex and use SendMsgThroughOEdges to send message like triangle:

messages.SendMsgThroughOEdges<fragment_t, int>(frag, v,
ctx.global_degree[v], tid);
});

But for the reason above, I use SendMsgThroughEdges for both directed graph and undirected graph, and the test case is ok to pass.

messages.SendMsgThroughEdges<fragment_t, int>(
frag, v, ctx.global_degree[v], tid);

Can you help me double check that SendMsgThroughEdges is ok for directed graph and undirected graph in the message passing between fragments? I don't want to bring another potential bug with the changes.

For directed graph, since we set message_strategy = grape::MessageStrategy::kAlongEdgeToOuterVertex, SendMsgThroughOEdges and SendMsgThroughEdges should behave the same. Same for undirected graphs.

@acezen
Copy link
Collaborator Author

acezen commented Apr 17, 2024

hi, @doudoubobo, since GraphScope only allow one MessageStrategy in one application:

static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongEdgeToOuterVertex;

for undirected graph, the strategy should be kAlongOutgoingEdgeToOuterVertex and use SendMsgThroughOEdges to send message like triangle:

messages.SendMsgThroughOEdges<fragment_t, int>(frag, v,
ctx.global_degree[v], tid);
});

But for the reason above, I use SendMsgThroughEdges for both directed graph and undirected graph, and the test case is ok to pass.

messages.SendMsgThroughEdges<fragment_t, int>(
frag, v, ctx.global_degree[v], tid);

Can you help me double check that SendMsgThroughEdges is ok for directed graph and undirected graph in the message passing between fragments? I don't want to bring another potential bug with the changes.

For directed graph, since we set message_strategy = grape::MessageStrategy::kAlongEdgeToOuterVertex, SendMsgThroughOEdges and SendMsgThroughEdges should behave the same. Same for undirected graphs.

thanks for the reply, since the approve dismiss by the fix push, can yo approve again to the PR.

@doudoubobo doudoubobo self-requested a review April 17, 2024 09:06
@acezen acezen merged commit b28ea01 into alibaba:main Apr 17, 2024
26 of 27 checks passed
@acezen acezen deleted the 3711-support-undirected-clustering branch April 17, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] wrong result of clustering function
3 participants