Skip to content

Commit 1da2b3d

Browse files
committed
5.0 dump and relate update
1 parent 2cbbf3b commit 1da2b3d

File tree

4 files changed

+1210
-241
lines changed

4 files changed

+1210
-241
lines changed

data/graph-data-science-50.dump

409 KB
Binary file not shown.

documentation/graph-data-science.adoc

+31-59
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ Now, let's import the data.
6161
.Create unique constraints on the names of the nodes `:Location`, `:Region`, `:Battle`, `:Person`, and `:House`. This ensures your data integrity and improves performance.
6262
[source, cypher]
6363
----
64-
CREATE CONSTRAINT ON (n:Location) ASSERT n.name IS UNIQUE;
65-
CREATE CONSTRAINT ON (n:Region) ASSERT n.name IS UNIQUE;
66-
CREATE CONSTRAINT ON (n:Battle) ASSERT n.name IS UNIQUE;
67-
CREATE CONSTRAINT ON (n:Person) ASSERT n.name IS UNIQUE;
68-
CREATE CONSTRAINT ON (n:House) ASSERT n.name IS UNIQUE;
64+
CREATE CONSTRAINT IF NOT EXISTS FOR (n:Location) REQUIRE (n.name) IS UNIQUE;
65+
CREATE CONSTRAINT IF NOT EXISTS FOR (n:Region) REQUIRE (n.name) IS UNIQUE;
66+
CREATE CONSTRAINT IF NOT EXISTS FOR (n:Battle) REQUIRE (n.name) IS UNIQUE;
67+
CREATE CONSTRAINT IF NOT EXISTS FOR (n:Person) REQUIRE (n.name) IS UNIQUE;
68+
CREATE CONSTRAINT IF NOT EXISTS FOR (n:House) REQUIRE (n.name) IS UNIQUE;
6969
----
7070

7171
.Then, ingest the data.
@@ -411,7 +411,7 @@ FOREACH (d IN dead_spouse |
411411
SET spouse:Dead
412412
);
413413
414-
MATCH (p:Person) where exists (p.death_year)
414+
MATCH (p:Person) where p.death_year is not null
415415
SET p:Dead;
416416
417417
MATCH (p:Person)-[:DEFENDER_KING|ATTACKER_KING]-()
@@ -559,15 +559,15 @@ To estimate the required memory for a subset of your graph, for example, the `Pe
559559

560560
[source, cypher]
561561
----
562-
CALL gds.graph.create.estimate('Person', 'INTERACTS') YIELD nodeCount, relationshipCount, requiredMemory
562+
CALL gds.graph.project.estimate('Person', 'INTERACTS') YIELD nodeCount, relationshipCount, requiredMemory
563563
----
564564

565565
The result shows that the example graph is small.
566566
So, you can create your projected graph and name it, for example, `got-interactions`.
567567

568568
[source, cypher]
569569
----
570-
CALL gds.graph.create('got-interactions', 'Person', 'INTERACTS')
570+
CALL gds.graph.project('got-interactions', 'Person', 'INTERACTS')
571571
----
572572

573573
== Estimate memory usage: algorithms
@@ -576,7 +576,7 @@ To estimate the memory needed to execute an algorithm on your `got-interactions`
576576

577577
[source, cypher]
578578
----
579-
CALL gds.pageRank.stream.estimate('got-interactions') YIELD requiredMemory
579+
CALL gds.pageRank.stream.estimate('got-interactions', {}) YIELD requiredMemory
580580
----
581581

582582
This estimation considers only the algorithm execution, as the graph is already in-memory.
@@ -588,29 +588,17 @@ The procedure returns a tree view and a map view of all the "components" with th
588588

589589
[source, cypher]
590590
----
591-
CALL gds.pageRank.stream.estimate('got-interactions')
591+
CALL gds.pageRank.stream.estimate('got-interactions', {})
592592
----
593593

594594
As you see, the more detailed views contain estimates on the individual compute steps and the result data structures.
595595

596-
You can also estimate the memory usage for graph creation and algorithm execution at the same time by using the so-called _implicit graph creation_.
597-
This way, the configuration for the graph creation is inlined within the algorithm procedure call.
598-
599-
[source, cypher]
600-
----
601-
CALL gds.pageRank.stream.estimate({nodeProjection: 'Person', relationshipProjection: 'INTERACTS'})
602-
----
603-
604-
The result shows an increased memory estimate, explained by the memory consumed by the graph creation.
605596

606597
Now, you can filter the result to the top level components: graph and algorithm.
607598

608599
[source, cypher]
609600
----
610-
CALL gds.pageRank.stream.estimate({
611-
nodeProjection: 'Person',
612-
relationshipProjection: 'INTERACTS'
613-
}) YIELD mapView
601+
CALL gds.pageRank.stream.estimate('got-interactions',{}) YIELD mapView
614602
UNWIND [ x IN mapView.components | [x.name, x.memoryUsage] ] AS component
615603
RETURN component[0] AS name, component[1] AS size
616604
----
@@ -655,7 +643,7 @@ Because each `INTERACTS` relationship is symmetric, you can even ignore its dire
655643

656644
[source, cypher]
657645
----
658-
CALL gds.graph.create('got-interactions', 'Person', {
646+
CALL gds.graph.project('got-interactions', 'Person', {
659647
INTERACTS: {
660648
orientation: 'UNDIRECTED'
661649
}
@@ -664,7 +652,7 @@ CALL gds.graph.create('got-interactions', 'Person', {
664652

665653
== Graph catalog: standard creation and Cypher projection
666654

667-
The GDS library supports two approaches for loading projected graphs - *standard creation* (`gds.graph.create()`) and *Cypher projection* (`gds.graph.create.cypher()`).
655+
The GDS library supports two approaches for loading projected graphs - *standard creation* (`gds.graph.project()`) and *Cypher projection* (`gds.graph.project.cypher()`).
668656

669657
In the *standard creation* approach, which you used to create your graph, you specify node labels and relationship types and project them onto the in-memory graph as labels and relationship types with new names.
670658
You can further specify properties for each node label and relationship type.
@@ -688,7 +676,7 @@ You need to return `id`, `source`, and `target` columns and can optionally retur
688676

689677
[source, cypher]
690678
----
691-
CALL gds.graph.create.cypher(
679+
CALL gds.graph.project.cypher(
692680
'got-interactions-cypher',
693681
'MATCH (n:Person) RETURN id(n) AS id',
694682
'MATCH (s:Person)-[i:INTERACTS]->(t:Person) RETURN id(s) AS source, id(t) AS target, i.weight AS weight'
@@ -709,7 +697,7 @@ The projected relationship does not exist in the stored graph.
709697

710698
[source, cypher]
711699
----
712-
CALL gds.graph.create.cypher(
700+
CALL gds.graph.project.cypher(
713701
'same-house-graph',
714702
'MATCH (n:Person) RETURN id(n) AS id',
715703
'MATCH (p1:Person)-[:BELONGS_TO]-(:House)-[:BELONGS_TO]-(p2:Person) RETURN id(p1) AS source, id(p2) AS target'
@@ -833,7 +821,7 @@ If you have removed it from the catalog, you have to create it again:
833821

834822
[source, cypher]
835823
----
836-
CALL gds.graph.create('got-interactions', 'Person', {
824+
CALL gds.graph.project('got-interactions', 'Person', {
837825
INTERACTS: {
838826
orientation: 'UNDIRECTED'
839827
}
@@ -881,7 +869,7 @@ Let's load a graph for the interactions in book 1 and compute and write the Page
881869

882870
[source, cypher]
883871
----
884-
CALL gds.graph.create(
872+
CALL gds.graph.project(
885873
'got-interactions-1',
886874
'Person',
887875
{
@@ -902,22 +890,6 @@ CALL gds.pageRank.write(
902890
)
903891
----
904892

905-
It is generally a good idea to explicitly create the graph before executing an algorithm.
906-
However, if you do not think that you will operate on this graph in the future, you can load it implicitly as part of the algorithm execution.
907-
908-
[source, cypher]
909-
----
910-
CALL gds.pageRank.write({
911-
nodeProjection: 'Person',
912-
relationshipProjection: {
913-
INTERACTS_1: {
914-
orientation: 'UNDIRECTED'
915-
}
916-
},
917-
writeProperty: 'pageRank-1'
918-
})
919-
----
920-
921893
== Page Rank: exercise
922894

923895
Let's see what you have learned so far.
@@ -943,7 +915,7 @@ You can find the solution on the next slide.
943915

944916
[source, cypher]
945917
----
946-
CALL gds.graph.create.cypher(
918+
CALL gds.graph.project.cypher(
947919
'house-battles',
948920
'MATCH (h:House) RETURN id(h) AS id',
949921
'MATCH (h1:House)-->(b:Battle)<--(h2:House) RETURN id(h1) AS source, id(h2) AS target, count(b) AS weight'
@@ -992,7 +964,7 @@ In LPA, the weight is used to determine the influence of neighboring nodes when
992964

993965
[source, cypher]
994966
----
995-
CALL gds.graph.create(
967+
CALL gds.graph.project(
996968
'got-interactions-weighted',
997969
'Person',
998970
{
@@ -1066,7 +1038,7 @@ Since 'got-interactions-weighted' does not contain the 'community' property, you
10661038

10671039
[source, cypher]
10681040
----
1069-
CALL gds.graph.create(
1041+
CALL gds.graph.project(
10701042
'got-interactions-seeded',
10711043
{
10721044
Person: {
@@ -1139,7 +1111,7 @@ If you have removed it from the catalog, you have to create it again:
11391111

11401112
[source, cypher]
11411113
----
1142-
CALL gds.graph.create('got-interactions', 'Person', {
1114+
CALL gds.graph.project('got-interactions', 'Person', {
11431115
INTERACTS: {
11441116
orientation: 'UNDIRECTED'
11451117
}
@@ -1163,7 +1135,7 @@ It will contain people that belong to the same culture.
11631135

11641136
[source, cypher]
11651137
----
1166-
CALL gds.graph.create.cypher(
1138+
CALL gds.graph.project.cypher(
11671139
'got-culture-interactions-cypher',
11681140
'MATCH (n:Person) RETURN id(n) AS id',
11691141
'MATCH (p1:Person)-[:MEMBER_OF_CULTURE]->(c:Culture)<-[:MEMBER_OF_CULTURE]-(p2:Person) RETURN id(p1) AS source, id(p2) AS target'
@@ -1204,7 +1176,7 @@ You will consider a graph with relationships weighted by the number of times a p
12041176

12051177
[source, cypher]
12061178
----
1207-
CALL gds.graph.create('got-wcc-weighted-interactions',
1179+
CALL gds.graph.project('got-wcc-weighted-interactions',
12081180
'Person',
12091181
{
12101182
INTERACTS: {
@@ -1259,7 +1231,7 @@ Then, you can create a projected graph, called `got-wcc-interactions-seeded` and
12591231

12601232
[source, cypher]
12611233
----
1262-
CALL gds.graph.create(
1234+
CALL gds.graph.project(
12631235
'got-wcc-interactions-seeded',
12641236
{
12651237
Person: {
@@ -1388,7 +1360,7 @@ If you have removed it from the catalog, you have to create it again:
13881360

13891361
[source, cypher]
13901362
----
1391-
CALL gds.graph.create('got-interactions', 'Person', {
1363+
CALL gds.graph.project('got-interactions', 'Person', {
13921364
INTERACTS: {
13931365
orientation: 'UNDIRECTED'
13941366
}
@@ -1426,7 +1398,7 @@ Otherwise, the number specified in `defaultValue` will be used as a fallback.
14261398

14271399
[source, cypher]
14281400
----
1429-
CALL gds.graph.create(
1401+
CALL gds.graph.project(
14301402
'got-weighted-interactions',
14311403
'Person',
14321404
{
@@ -1544,7 +1516,7 @@ You create the graph using the following query:
15441516

15451517
[source, cypher]
15461518
----
1547-
CALL gds.graph.create('got-character-related-entities', ['Person', 'Book', 'House', 'Culture'], '*')
1519+
CALL gds.graph.project('got-character-related-entities', ['Person', 'Book', 'House', 'Culture'], '*')
15481520
----
15491521

15501522
This graph creation uses projection with multiple node labels.
@@ -1710,7 +1682,7 @@ Let us verify with the triangle count procedure executed on the same subgraph as
17101682

17111683
[source, cypher]
17121684
----
1713-
CALL gds.graph.create.cypher('small_got',
1685+
CALL gds.graph.project.cypher('small_got',
17141686
'MATCH (n:Person) RETURN id(n) AS id',
17151687
"MATCH (n:Person)-[r:INTERACTS_1]->(m:Person)
17161688
WHERE n.name IN ['Robb Stark', 'Tyrion Lannister'] RETURN id(n) AS source, id(m) AS target
@@ -1735,7 +1707,7 @@ For finding the people with the highest overall triangle count in book 1, we can
17351707
.This will create the named graph we are going to use in the examples (run if not already created)
17361708
[source, cypher]
17371709
----
1738-
CALL gds.graph.create(
1710+
CALL gds.graph.project(
17391711
'got-interactions-1',
17401712
'Person',
17411713
{
@@ -1824,7 +1796,7 @@ For finding the people with the highest overall local clustering coefficient in
18241796
.This will create the named graph we are going to use in the examples (run if not already created)
18251797
[source, cypher]
18261798
----
1827-
CALL gds.graph.create(
1799+
CALL gds.graph.project(
18281800
'got-interactions-1',
18291801
'Person',
18301802
{
@@ -1920,7 +1892,7 @@ If you have removed it from the catalog, you have to create it again:
19201892

19211893
[source, cypher]
19221894
----
1923-
CALL gds.graph.create('got-interactions', 'Person', {
1895+
CALL gds.graph.project('got-interactions', 'Person', {
19241896
INTERACTS: {
19251897
orientation: 'UNDIRECTED'
19261898
}

0 commit comments

Comments
 (0)