I’m aware of the rand()
function but I couldn’t figure out how to get e.g. 10 randomly selected vertices out of all existing vertices.
Any hints?
Hi Grizard,
By nature the GSQL SELECT
statement is psuedo-random.
The below SELECT will return different results each time it is run.
random = SELECT s
FROM S:s
LIMIT 10;
If you are looking to randomly sample edges or using a qualifier more than a source vertex set, you can use the SAMPLE
clause.
random = SELECT s
FROM S:s - (:e) - :v
SAMPLE 10 TARGETS
3 Likes
Dan, thanks for your answer. However re-running the first statement multiple results in the very same nodes each time. Is there a way to get a different result set each time?
1 Like
Can also do this with the pyTigerDriver, e.g., using
conn.getVertexDataframe(“your_node_type”, limit = 3)