http://franz.com/ns/allegrograph/4.11/sna/communityLeiden
Magic property sna:communityLeiden
implements Leiden Community Detection algorithm, it takes a list of keyword arguments:
Name | Type | Default | Optional | Description |
generator | Resource | nil | yes | A defined SNA generator |
actor | Resource | nil | yes | A start node (actor) for traversing the RDF graph by the generator |
depth | Numeric or nil | nil | yes | The depth for making an ego group. Must not be nil if generator is non- nil . See note 1 following the table. |
selector | Resource | nil | yes | A defined SNA selector |
resolution | Numeric | 1.0 | yes | A parameter that is used when computing the modularity |
beta | Numeric | 0.01 | yes | A parameter that controls the randomness while breaking a community into smaller ones |
iterations | Numeric | -1 | yes | A parameter that controls the total iterations. -1 means iterate until modularity cannot be improved further. |
seed | Numeric or nil | nil | yes | A parameter that sets the random generator’s seed to have re-producible communities |
Note 1 The depth argument can only be nil
when the generator argument is not specified or nil
. Otherwise, depth must be a non-negative integer and will be used along with the generator
and actor
for constructing an SNA ego group.
Note that, users must supply either a generator
or a selector
. When the computation is done, it returns detected communities as ego groups (fully compatible with other operations e.g. sna:groupDegreeCentrality
, and each group will be assigned with an integer community ID. For example, the query below not only runs a leiden cummunity detection, but also inserts new triples by utilizing the returned ego groups as well as IDs:
PREFIX sna: <http://franz.com/ns/allegrograph/4.11/sna/>
PREFIX : <http://franz.com/ns/keyword#>
PREFIX ex: <ex://#>
INSERT {
?communityId rdf:type sna:Community .
?actor sna:communityMember ?communityId .
}
WHERE {
(?group ?groupId) sna:communityLeiden (:selector ex:someSelector :seed 1000) .
BIND (IRI(concat("ex://#Community-", str(?groupId) )) AS ?communityId) .
?actor sna:members ?group .
}
Notes
The following namespace abbreviations are used:
- fti - <http://franz.com/ns/allegrograph/2.2/textindex/>
- geo - <http://franz.com/ns/allegrograph/3.0/geospatial/>
- geofn - <http://franz.com/ns/allegrograph/3.0/geospatial/fn/>
- nd - <http://franz.com/ns/allegrograph/5.0/geo/nd#>
- ndfn - <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
- sna - <http://franz.com/ns/allegrograph/4.11/sna/>
The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.