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

Extract random walks efficiently #70

Closed
wouterbeek opened this issue Jun 30, 2017 · 3 comments
Closed

Extract random walks efficiently #70

wouterbeek opened this issue Jun 30, 2017 · 3 comments

Comments

@wouterbeek
Copy link
Contributor

Since it's possible to extract the estimated number of results for an arbitrary triple pattern, we were wondering whether it would also be possible to efficiently retrieve, for a given node X, a random neighbor node Y of X (in constant time).

Looking at the Web Semantics paper from 2013, it seems that this should be doable by querying bitmap triples representation directly.

Thanks in advance!
@airobert and @wouterbeek

@airobert
Copy link

airobert commented Jul 8, 2017

@webdata
Copy link
Contributor

webdata commented Sep 7, 2017

This is a first attempt (depends on the "goto" issue #84)

int searchID_subject = mydictionary.stringToId("http://yourinitialNOde", TripleComponentRole.SUBJECT);

TripleID pattern = new TripleID(searchID, 0, 0);
IteratorTripleID it = mytriples.search(pattern);
size_t numResults = it.estimatedNumResults();

int randNumber = 1+int(numResults*rand()/(RAND_MAX + 1.0));

it.goTo(randNumber);

TripleID result=it.next();

@webdata
Copy link
Contributor

webdata commented Sep 19, 2017

Solved with latests commits in develop, 7b92caa

See tool https://github.com/rdfhdt/hdt-cpp/blob/develop/hdt-lib/tests/randomSolution.cpp implementing an example

@webdata webdata closed this as completed Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants