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

Update 2.graph-modeling.md #1221

Merged
merged 5 commits into from
Apr 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs-2.0/8.service-tuning/2.graph-modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,54 @@ nebula> MATCH (v1:player)-[e:temp]->() return collect(e.tmp);
+----------------+
```

### About dangling edges

A dangling edge is an edge that only connects to a single vertex and only one part of the edge connects to the vertex.

In Nebula Graph {{ nebula.release }}, dangling edges may appear in the following two cases.

1. Insert edges with [INSERT EDGE](../3.ngql-guide/13.edge-statements/1.insert-edge.md) statement before the source vertex or the destination vertex exists.

2. Delete vertices with [DELETE VERTEX](../3.ngql-guide/12.vertex-statements/4.delete-vertex.md) statement and the `WITH EDGE` option is not used. At this time, the system does not delete the related outgoing and incoming edges of the vertices. There will be dangling edges by default.

Dangling edges may appear in Nebula Graph {{nebula.release}} as the design allow it to exist. And there is no MERGE statement like openCypher has. The existence of dangling edges depends entirely on the application level. You can use [GO](../3.ngql-guide/7.general-query-statements/3.go.md) and [LOOKUP](../3.ngql-guide/7.general-query-statements/5.lookup.md) statements to find a dangling edge, but cannot use the [MATCH](../3.ngql-guide/7.general-query-statements/2.match.md) statement to find a dangling edge.

Examples:

```bash
// Insert an edge that connects two vertices which do not exist in the graph. The source vertex's ID is '11'. The destination vertex's ID is'13'.

nebula> CREATE EDGE IF NOT EXISTS e1 (name string, age int);
nebula> INSERT EDGE e1 (name, age) VALUES "11"->"13":("n1", 1);

// Query using the `GO` statement

nebula> GO FROM "11" over e1 YIELD properties(edge);
+----------------------+
| properties(EDGE) |
+----------------------+
| {age: 1, name: "n1"} |
+----------------------+

// Query using the `LOOKUP` statement

nebula> LOOKUP ON e1 YIELD EDGE AS r;
+-------------------------------------------------------+
| r |
+-------------------------------------------------------+
| [:e2 "11"->"13" @0 {age: 1, name: "n1"}] |
+-------------------------------------------------------+

// Query using the `MATCH` statement

nebula> MATCH ()-[e:e1]->() RETURN e LIMIT 100;
+---+
| e |
+---+
+---+
Empty set (time spent 3153/3573 us)
```

### Breadth-first traversal over depth-first traversal

- Nebula Graph has lower performance for depth-first traversal based on the Graph topology, and better performance for breadth-first traversal and obtaining properties. For example, if model A contains properties "name", "age", and "eye color", it is recommended to create a tag `person` and add properties `name`, `age`, and `eye_color` to it. If you create a tag `eye_color` and an edge type `has`, and then create an edge to represent the eye color owned by the person, the traversal performance will not be high.
Expand Down