@@ -495,8 +495,7 @@ The other community is assigned a new community ID, which is guaranteed to be la
495
495
Note that the `consecutiveIds` configuration option cannot be used in combination with seeding in order to retain the seeding values.
496
496
497
497
498
- [[algorithms-louvain-examples-stream-intermediate]]
499
- === Stream intermediate communities
498
+ === Using intermediate communities
500
499
501
500
As described before, Louvain is a hierarchical clustering algorithm.
502
501
That means that after every clustering step all nodes that belong to the same cluster are reduced to a single node.
@@ -569,6 +568,10 @@ CALL gds.graph.project(
569
568
)
570
569
----
571
570
571
+
572
+ [[algorithms-louvain-examples-stream-intermediate]]
573
+ ==== Stream intermediate communities
574
+
572
575
[role=query-example]
573
576
--
574
577
.The following run the algorithm and stream results including the intermediate communities:
@@ -603,3 +606,117 @@ ORDER BY name ASC
603
606
--
604
607
605
608
In this example graph, after the first iteration we see 4 clusters, which in the second iteration are reduced to three.
609
+
610
+
611
+ [[algorithms-louvain-examples-mutate-intermediate]]
612
+ ==== Mutate intermediate communities
613
+
614
+ [role=query-example, group=mutateIntermediateCommunities]
615
+ --
616
+ .The following run the algorithm and mutate the in-memory graph:
617
+ [source, cypher, role=noplay]
618
+ ----
619
+ CALL gds.louvain.mutate('myGraph2', {
620
+ mutateProperty: 'intermediateCommunities',
621
+ includeIntermediateCommunities: true
622
+ })
623
+ YIELD communityCount, modularity, modularities
624
+ ----
625
+
626
+ .Results
627
+ [opts="header"]
628
+ |===
629
+ | communityCount | modularity | modularities
630
+ | 3 | 0.3816 | [0.37599999999999995, 0.3816]
631
+ |===
632
+ --
633
+
634
+ [role=query-example, group=mutateIntermediateCommunities]
635
+ --
636
+ .The following stream the mutated property from the in-memory graph:
637
+ [source, cypher, role=noplay]
638
+ ----
639
+ CALL gds.graph.streamNodeProperty('myGraph2', 'intermediateCommunities')
640
+ YIELD nodeId, propertyValue
641
+ RETURN
642
+ gds.util.asNode(nodeId).name AS name,
643
+ toIntegerList(propertyValue) AS intermediateCommunities
644
+ ORDER BY name ASC
645
+ ----
646
+
647
+ .Results
648
+ [opts="header"]
649
+ |===
650
+ | name | intermediateCommunities
651
+ | "a" | [3, 14]
652
+ | "b" | [3, 14]
653
+ | "c" | [14, 14]
654
+ | "d" | [3, 14]
655
+ | "e" | [14, 14]
656
+ | "f" | [14, 14]
657
+ | "g" | [7, 7]
658
+ | "h" | [7, 7]
659
+ | "i" | [7, 7]
660
+ | "j" | [12, 12]
661
+ | "k" | [12, 12]
662
+ | "l" | [12, 12]
663
+ | "m" | [12, 12]
664
+ | "n" | [12, 12]
665
+ | "x" | [14, 14]
666
+ |===
667
+ --
668
+
669
+
670
+ [[algorithms-louvain-examples-write-intermediate]]
671
+ ==== Write intermediate communities
672
+
673
+ [role=query-example, group=writeIntermediateCommunities]
674
+ --
675
+ .The following run the algorithm and write to the Neo4j database:
676
+ [source, cypher, role=noplay]
677
+ ----
678
+ CALL gds.louvain.write('myGraph2', {
679
+ writeProperty: 'intermediateCommunities',
680
+ includeIntermediateCommunities: true
681
+ })
682
+ YIELD communityCount, modularity, modularities
683
+ ----
684
+
685
+ .Results
686
+ [opts="header"]
687
+ |===
688
+ | communityCount | modularity | modularities
689
+ | 3 | 0.3816 | [0.37599999999999995, 0.3816]
690
+ |===
691
+ --
692
+
693
+ [role=query-example, group=writeIntermediateCommunities]
694
+ --
695
+ .The following stream the written property from the Neo4j database:
696
+ [source, cypher, role=noplay]
697
+ ----
698
+ MATCH (n:Node) RETURN n.name AS name, toIntegerList(n.intermediateCommunities) AS intermediateCommunities
699
+ ORDER BY name ASC
700
+ ----
701
+
702
+ .Results
703
+ [opts="header"]
704
+ |===
705
+ | name | intermediateCommunities
706
+ | "a" | [3, 14]
707
+ | "b" | [3, 14]
708
+ | "c" | [14, 14]
709
+ | "d" | [3, 14]
710
+ | "e" | [14, 14]
711
+ | "f" | [14, 14]
712
+ | "g" | [7, 7]
713
+ | "h" | [7, 7]
714
+ | "i" | [7, 7]
715
+ | "j" | [12, 12]
716
+ | "k" | [12, 12]
717
+ | "l" | [12, 12]
718
+ | "m" | [12, 12]
719
+ | "n" | [12, 12]
720
+ | "x" | [14, 14]
721
+ |===
722
+ --
0 commit comments