Sampling all that connected to a small number of nodes

I want to create a subgraph of the big graph.
For this, I want to choose a small number of nodes (say 100) and for these nodes to include EVERYTHING that is connected to them, even at a big distance (neighbor of neighbor or neighbor etc).

Any idea how to perform this?

@yaakovtayeb If you’re looking to start from a specific node and explore outwards you could take this and modify it. The depth would be how many neighbors of neighbors you would like to visit.

CREATE QUERY khop(VERTEX<MyNode> start_node, INT depth) for graph GraphName{

    OrAccum          @visited = false;
    SumAccum<int>    @@loop=0;

    Start = {start_node};
    Start = SELECT v
            FROM Start:v
            ACCUM v.@visited = true;

    WHILE (@@loop < depth) DO
        Start = SELECT v
                FROM Start:u - (MyEdge:e)->:v
                WHERE v.@visited == false
                ACCUM v.@visited = true;

        @@loop += 1;
   END;

   PRINT Start.size();
}
1 Like

I’ll give it a try!
thanks!

1 Like