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

It seems like no implementation of metapath-based random walks. #2

Open
skx300 opened this issue Apr 3, 2018 · 3 comments
Open

It seems like no implementation of metapath-based random walks. #2

skx300 opened this issue Apr 3, 2018 · 3 comments

Comments

@skx300
Copy link

skx300 commented Apr 3, 2018

It seems like no implementation of metapath-based random walks. Any help for finding it? or is it quit easy to implement it ?

@apple2373
Copy link
Owner

apple2373 commented Apr 3, 2018

I think it is easy to implement or modify existing random walk implementation. An easy (but not most efficient) way is to store node-type matrix whose size is (number of nodes) x (number of node types). It's a binary matrix. Then, every time you need to sample a specific node of a type, you can use a row as a binary mask to the corresponding row of the adjacent matrix.

For example, let A adjacent matrix and let T as type matrix.
so

  • A is the (number of nodes) x (number of nodes) matrix.
  • T is the (number of nodes) x (number of node types) matrix.

Assume that the random walker is at the node 10, and you need to sample an adjacent node whose type is 4. If you ignore about the node type requirement, you usually do

Sample a non-zero index from the 10th row vector of A (say, A[10,:]).

Right?

Then when you need to limit to type 4, you use 4th row vector of T (say, T[4,:]). Then multiply to A[10,:] in a element wise manner.

Then,

Sample a non zero index from A[10,:]*T[4,:] .

This will automatically meet the type requirements.

Does this make sense?

@skx300
Copy link
Author

skx300 commented Apr 3, 2018

Thank you. I understand that. But should sample the A[10, :] * T[:4], right? The T is in shape (number of nodes) x (number of node types). The column of T does the mask, instead of the row.

@apple2373
Copy link
Owner

apple2373 commented Apr 3, 2018 via email

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

No branches or pull requests

2 participants