PageRank
The PageRank algorithm ranks the nodes in a graph by their relative importance or influence. PageRank determines each node's ranking by identifying the number of links to the node and the quality of the links. The quality of a link is determined by the importance (PageRank) of the node that presents the outbound link.
PageRank Syntax
Graph algorithms are accessed from an internal SPARQL service endpoint. To incorporate the PageRank algorithm in a query, include a SERVICE statement in the WHERE clause. The service call specifies the name of the algorithm and defines the required and optional property values for that algorithm.
Use the following syntax in the SERVICE clause to compute the PageRank for nodes in a graph. The table below describes each property.
SERVICE <csi:page_rank> { [] <csi:binding-vertex> ?vertex_variable_name ; <csi:binding-rank> ?rank_variable_name ; <csi:edge-label> <edge_uri> ; [ <csi:graph> <graph_uri> ; ] [ <csi:max-iterations> number_of_iterations ; ] [ <csi:err-tolerance> tolerance_number ; ] [ <csi:damping-factor> double_value ; ] [ <csi:normalized> boolean_value ] }
PageRank Examples
The examples below are run against a sample flight network data set, which contains data about flights, airlines, and airport locations. For instructions on downloading the sample data and loading it to AnzoGraph DB so that you can run the example queries, see Sample Data for Graph Algorithm Examples.
The example below uses the PageRank algorithm to find the 10 most connected airports. The edge to operate on is defined as the hasRouteTo URI, which links the airport nodes.
prefix : <http://anzograph.com/data#> prefix fl: <http://anzograph.com/flights/> prefix owl: <http://www.w3.org/2002/07/owl#> prefix skos: <http://www.w3.org/2004/02/skos/core#> SELECT ?airport ?rank FROM <http://anzograph.com/airline_flight_network> WHERE { ?node a fl:Airport . ?node skos:prefLabel ?airport . SERVICE <csi:page_rank> { [] <csi:binding-vertex> ?node ; <csi:binding-rank> ?rank ; <csi:edge-label> <http://anzograph.com/flights/hasRouteTo> . } } ORDER BY desc(?rank) LIMIT 10
The results show that Chicago O'Hare has the highest PageRank. It has the highest number of links to other airports.
airport | rank ---------------------------------------------------+--------- Chicago O'Hare International Airport | 13.4122 Dallas Fort Worth International Airport | 13.1632 Hartsfield Jackson Atlanta International Airport | 12.8073 Denver International Airport | 10.3813 George Bush Intercontinental Houston Airport | 8.38146 Salt Lake City International Airport | 6.9018 Minneapolis-St Paul International/Wold-Chamberlain | 6.24394 San Francisco International Airport | 5.50726 Phoenix Sky Harbor International Airport | 5.27481 Los Angeles International Airport | 5.24544 10 rows