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

A query statement to retrieve a sub-graph #166

Closed
sherman-the-tank opened this issue Feb 26, 2019 · 3 comments
Closed

A query statement to retrieve a sub-graph #166

sherman-the-tank opened this issue Feb 26, 2019 · 3 comments
Assignees
Milestone

Comments

@sherman-the-tank
Copy link
Member

We need a new query statement to retrieve the entire sub-graph from one or multiple vertices. The sub-graph needs to include all edges not only starting from the given vertices, but also between any two vertices in the sub-graph

@sherman-the-tank sherman-the-tank added this to the beta_release milestone Feb 26, 2019
@dutor dutor self-assigned this Feb 27, 2019
@sherman-the-tank sherman-the-tank removed this from the v1_beta_release milestone May 30, 2019
@jude-zhu jude-zhu modified the milestones: R201910_RC1, R201910_RC2 Aug 7, 2019
@jude-zhu jude-zhu modified the milestones: R201910_RC2, R201910_RC3 Nov 21, 2019
@laura-ding
Copy link
Contributor

The syntax for getting subgraph

GET SUBGRAPH 2 steps from vid over <edgeTypeList|*> <empty|REVERSELY|BOTH> [WHERE V1.tag_name.prop > 10] [YIELD V0.tag_name.prop, V1.tag_name.prop, V2.tag_name.prop, E1.edge_type.prop, E2.edge_type.prop]

V0 is the starting vertex, V1 is the first-degree vertices, V2 is the second-degree vertices.
E1 is the first-degree edges, E2 is the second-degree edges
If not YIELD, return the vertex id and edge type

The result is JSON format, return all paths from the start vertex. The returned data set has redundant data because it is returned by path.

@jude-zhu
Copy link
Contributor

FYR, subgraph syntax of cypher is:

apoc.path.subgraphAll(startNode <id>Node/list, {minLevel, maxLevel, relationshipFilter, labelFilter, bfs:true, filterStartNode:true, limit:-1}) yield nodes, relationships

Example. Expand to local subgraph (and all its relationships) within 4 traversals:

MATCH (company:Company) WHERE company.name = "RENTON COLLECTIONS INC."
CALL apoc.path.subgraphAll(company, {maxLevel:4}) YIELD nodes, relationships
RETURN nodes, relationships;

Result in table format:

屏幕快照 2019-12-24 上午11 26 56

In text format:

屏幕快照 2019-12-24 上午11 27 16

In graph format:

屏幕快照 2019-12-24 上午11 27 28

@sherman-the-tank
Copy link
Member Author

Very good start point. Here are couple things I can think of

  1. Instead of keyword "BOTH" in the edge specification, I would suggest to use "BIDIRECTIONALLY" (or abbreviate to "BIDIRECT"). It is more meaningful

  2. In the YIELD sentence, I'm afraid V1, V2.. E1, E2.. are insufficient, because some vertices could be the result of multiple hops (ie. a vertex could be the result of 2-hop, and the result of 3-hop), same as the edges

@jude-zhu jude-zhu modified the milestones: R201910_RC3, R201910_RC4 Dec 25, 2019
@jude-zhu jude-zhu modified the milestones: R201910_RC4, v2.0.0 Mar 2, 2020
@jude-zhu jude-zhu added the v2.0 label May 26, 2020
yixinglu pushed a commit to yixinglu/nebula that referenced this issue Mar 21, 2022
Co-authored-by: kyle.cao <kyle.cao@vesoft.com>
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

5 participants