Jump to content

User:Aisha Khatun/Wikidata Subgraph Analysis

TL;DR

  • All items and item statements that are instance of of X are considered subgraph of X. Some obvious subgraphs were merged into one.
  • 0.5% (~400) subgraphs form 90% of Wikidata (triples and items). Subgraph size visualization: subgraph stats
  • List of Top 50 subgraps: #Table_of_top_50_subgraph_information
  • The most common top predicates in the subgraphs are description, rdf:type, wikibase:rank, and references.
  • The growth rate of all subgraphs look consistent yet stable. None of them are growing at an unprecedented rate, but growing nonetheless. Growth rate visualization: subgraph_growth_rate
  • A visualization to show the connectivity between the top 50 subgraphs and how strong the connections are: wikidata_graph
    • Almost all subgraphs are connected to most other subgraphs in one way or other
    • Most connections are through triples
    • Subgraphs that share items are considered more connected (therefore, heavily weighted edges)
    • No isolated subgraph group or cluster was found in the top 50 subgraphs
    • The larger the subgraph gets, the more connections to other subgraphs it has
  • A list of the subgraph pairs that have the common items: nonzero_subgraph_pair_detail.csv. While most of the pairs seem reasonable, such as mountain-hill, some pairs seem odd, like village-human. This list can be used as a guide to solve some of the errors in Wikidata.

What are subgraphs?

Wikidata contains all kinds of data from various aspects of knowledge. All of these data are highly inter-connected, but we can find some patterns. We find subgraphs within Wikidata and find out how large these subgraphs are, how connected they are, and finally how much these subgraphs are used (queried).

In order to find subgraphs, the following steps were taken:

  • Consider all items that are instance of (P31) the same item to be under a subgraph. For example: all items that are instance of Q13442814 are part of one subgraph.
  • Some subgraphs were merged where it was obvious. For example: all subclasses of astronomical object were considered part of astronomical object as they were all indeed some sort of astronomical object. This method of sublcass merging is not applicable everywhere without manual inspection.
  • Some large subgraphs were almost completely part of another subgraph. For example: all items under Review Articles are also instance of scholarly article. In such case, review articles was not considered a separate subgraph.

Subgraph sizes

Using only instance of, Wikidata has 82,919 subgraphs. The distribution of the sizes of these subgraphs has a clear long tail, with very few subgraphs incorporating most items in Wikidata. Subgraph size can be calculated in two ways:

  • The number of items it contains
  • The number of triples related to the items in a subgraph. This is what we refer as subgraph size from here on.

Takeaways:

  • Most calculations from here on will take the top 50 subgraphs, which form 85% of Wikidata
  • 340 top subgraphs (0.5% of all subgraphs, after merging some) form 90% of Wikidata (91% of all items and 90% of all triples). These subgraphs have >=10,000 items each.
  • Rest 99.5% of the subgraphs have <10,000 items each, and together form 10% of Wikidata.

Below is the distribution of the number of items in a subgraphs.

To be more specific,

Subgraph item distribution
Number of subgraphsNumber of items
There are 54,602 subgraph(s) with more than 1 item(s)
23,72410
6,625100
1,7121,000
39210,000
63100,000
101,000,000
110,000,000

Below is the subgraph size comparison of top 340 subgraphs in Wikidata (90%).

Below is the subgraph size comparison of top 50 subgraphs in Wikidata (85%).

Here is an interactive graph showing the comparison of subgraph sizes in terms of item count and triple count: subgraph stats.

Here are some subgraph size visualizations in WDQS:

  • Size as percentage of Wikidata each subgraph occupies: query link
  • Size as percentage of Wikidata items each subgraph contains: query link

Number of days to recovery Given the current rate of growth, how long would it take wikidata to get back to its original size again if some amount of triples were removed from it? This helps us estimate what to temporarily remove from Wikidata in the siatuation Wikidata backend maxes out. The growth rate of triples is not constant, but considering the growth an approximate straight line, in grafana dashboard, Wikidata grows at a rate of 4.77M triples per day. This rate was calculated from the number of triples at the start and end of a 90-day interval (11/3/21 to 6/6/21). It could be faster or a bit slower than this. This will give us a wide approximation of the number of days we can gain by removing some parts of Wikidata.

Triples

The triples within a subgraph can be of various types. They can be:

  • truthy triples like wdt
  • non-wikidata direct triples like rdfs:label, schema:name etc
  • full statements that hold other information

See more about these statement types here: RDF_Dump_Format#Statement_types.

Table of top 50 subgraph information

Top 50 Subgraphs in Wikidata
RankSubgraphSubgraph NameNumber of items% of WD itemsNumber of triples% of WD TriplesNumber of days to recover%of truthy statements%of non-wikidata direct statements%of full statementsNumber of unique properties
1Q13442814scholarly article37,362,64139.756,539,020,88949.731370.8612.6224.2863.25722
2Q6999astronomical object8,412,9148.951,136,682,2918.64238.310.2014.2476.07578
3Q5human9,315,4449.91954,536,9437.26200.1113.3120.0660.944482
4Q4167836Wikimedia category4,840,1955.15753,127,9825.73157.891.1986.065.19610
5Q16521taxon3,180,2483.38367,926,4622.877.1310.1137.2242.97963
6Q101352family name481,4450.51187,299,8921.4239.271.5993.496.62375
7Q4167410Wikimedia disambiguation page1,359,8041.45180,124,1741.3737.760.8988.323.83796
8Q7187gene1,196,3611.27122,421,5080.9325.6614.1312.5173.11218
9Q11266439Wikimedia template845,8520.9114,308,7110.8723.960.7887.063.20222
10Q11173chemical compound1,223,3871.391,228,4630.6919.1312.6935.7250.86591
11Q8054protein986,5991.0588,483,8280.6718.5514.2613.5172.21267
12Q3305213painting539,4680.5756,769,0830.4311.912.1024.4663.35785
13Q13100073village-level division in China588,4770.6351,615,5720.3910.826.8462.7330.4177
14Q11424film263,0700.2847,176,0670.369.8914.3712.7466.011029
15Q486972human settlement563,9580.639,590,7920.38.310.8422.9449.321120
16Q13406463Wikimedia list article334,9390.3633,742,2450.267.072.4578.0610.48880
17Q13433827encyclopedia article512,1410.5533,373,2270.257.09.0345.5239.76164
18Q8502mountain525,5530.5633,340,1880.256.9911.3727.7950.39709
19Q2668072collection500,9680.5332,670,6370.256.8515.2412.3072.71665
20Q79007street578,9260.6230,252,1190.236.3413.8624.2459.88572
21Q4022river399,5520.4228,833,4760.226.0411.3424.9952.15580
22Q30612clinical trial356,8380.3827,731,5020.215.8116.0512.3371.78124
23Q532village274,8400.2926,483,2750.25.559.6926.2545.22818
24Q17633526Wikinews article286,9500.321,830,1500.174.583.6872.7616.46256
25Q482994album269,0950.2921,181,0150.164.4412.2022.6453.05638
26Q23397lake260,1350.2818,053,0960.143.7811.3225.4353.19602
27Q54050hill327,2770.3517,228,3900.133.6112.6723.0756.77470
28Q16970church building211,2910.2216,821,5300.133.5314.0315.0663.561036
29Q41176building265,9250.2816,293,0080.123.4214.2114.9968.061243
30Q56436498village in India145,8240.1615,383,4160.123.238.3422.2364.50210
31Q4830453business193,8580.2114,101,2200.112.9613.0616.2360.481790
32Q47150325calendar day of a given year189,3660.214,078,4860.112.956.8556.2534.1856
33Q3947house197,7360.2112,468,4340.12.6115.2615.1870.67760
34Q3331189version, edition, or translation157,4860.1710,997,5890.082.3115.4114.7069.391006
35Q18593264item of collection or exhibition147,4020.1610,732,9690.082.2516.969.6973.38306
36Q27020041sports season158,8770.1710,693,5040.082.2412.1115.1253.43353
37Q355304watercourse174,6200.1910,080,4210.082.1112.1725.0754.79302
38Q7725634literary work164,8600.1810,049,5210.082.1113.8516.6958.881093
39Q23442island148,5870.169,885,2770.082.0711.4022.5250.06829
40Q11060274print119,8060.139,700,0630.072.0314.859.7476.96269
41Q811979architectural structure145,9570.169,666,9360.072.0310.069.9152.63994
42Q5084hamlet118,1880.139,013,5340.071.8910.9418.6355.55423
43Q9842primary school157,4510.178,916,3730.071.8713.9916.2268.98410
44Q19389637biographical article151,0260.168,238,3970.061.7312.7621.0757.51131
45Q21014462cell line128,8050.147,955,9750.061.6710.6236.1854.6060
46Q47521stream124,8530.136,654,3660.051.412.9519.6758.11280
47Q59199015group of stereoisomers111,5990.125,843,2700.041.2315.4318.8267.23216
48Q61443690branch post office129,1830.145,313,0330.041.1114.5914.8670.5422
49Q49008prime number127,5450.145,188,7680.041.0910.0136.7852.40101
50Q4164871position120,1170.134,720,6680.040.9912.7232.7652.28654

Triples per item

While it is interesting to see how big a subgraph is and how many items it has, it is helpful to know how many triples each item has typically in a given subgraph. A very basic idea can be gained from density of a subgraph, where density = #of triples / #of items, in subgraph stats. Below is a diagram of box plot showing triples per item distribution for the top 50 subgraphs. The box plot omits min and max values, shows only mean, median, Q1, and Q3.

Predicates

Predicates are used in all subgraph. Sometimes some predicates are almost exclusively used in a particular subgraphs, other times a predicate may be used 99% of times in that particular subgraph. Moreover, the unique predicates used in a subgraph can inform us of the range of diverse statements a subgraph contains. These and some more analysis were done on predicates below.

Number of unique predicates

The number of unique predicates a subgraph uses has been listed in the table above (#Table of top 50 subgraph information). Feel free to sort by property column to view the most/least diverse subgraph.

Predicate distribution

There are ~7500 unique predicates across the top 50 subgraphs. Among them ~3500(46%) are used in any 1 subgraph only. Below is a figure showing this distribution.

Here is a csv file to the subgraph-predicate count: subgraph_pred_df_info.csv.

Top predicates

While it is interesting to see the top predicates for each subgraph, it is too much to view for this page. Below is a table of only the top 3 predicates per subgraph. Here is a csv file with the top 5 predicates per subgraph: top_subgraph_pred.csv. You can view more from subgraph_pred_df_info.csv with some filtering and grouping.

Note that:

  • The most common top predicates are description, rdf:type, wikibase:rank, and references.
  • Only scholarly articles' descriptions are 10% of Wikidata, with cites work and wikibase:rank being ~6%.
  • Wikimedia category descriptions are 4.5%, and the rest is ~1% or less of Wikidata triples.
Top predicates per subgraph and their triple distribution
1st top predicate 2nd top predicate 3rd top predicate
Subgraph Predicate#of triples%triples in subgraph%triples in Wikidata Predicate#of triples%triples in subgraph%triples in Wikidata Predicate#of triples%triples in subgraph%triples in Wikidata
Wikimedia categorydescription59667207679.2264.51722-rdf-syntax-ns#type227615313.0220.172rdf-schema#label150947712.0040.114
Wikimedia disambiguation pagedescription11226492262.3260.85rdf-schema#label3958718021.9780.322-rdf-syntax-ns#type41461982.3020.031
Wikimedia list articledescription2371460970.2820.1822-rdf-syntax-ns#type14490154.2940.011instance of10224243.030.008
Wikimedia templatedescription9328638581.6090.70622-rdf-syntax-ns#type29189072.5540.022instance of25570942.2370.019
Wikinews articledescription1412843664.720.10722-rdf-syntax-ns#type11149215.1070.008instance of8620833.9490.007
album22-rdf-syntax-ns#type279306713.1870.021ontology#rank225045710.6250.017rdf-schema#label18716418.8360.014
architectural structureontology#rank129096913.3540.0122-rdf-syntax-ns#type128914913.3360.01prov#wasDerivedFrom7255557.5060.005
astronomical objectontology#rank14457882812.7191.095prov#wasDerivedFrom12833195511.290.97222-rdf-syntax-ns#type11713772710.3050.887
biographical article22-rdf-syntax-ns#type121252914.7180.009ontology#rank106139512.8840.008description5323276.4620.004
branch post office22-rdf-syntax-ns#type77543614.5950.006ontology#rank77543614.5950.006prov#wasDerivedFrom64562812.1520.005
building22-rdf-syntax-ns#type237276014.5630.018ontology#rank226292513.8890.017prov#wasDerivedFrom11301586.9360.009
business22-rdf-syntax-ns#type194808713.8150.015ontology#rank166929511.8380.013prov#wasDerivedFrom9191846.5180.007
calendar day of a given yearrdf-schema#label615205243.6980.047instance of11464608.1430.00922-rdf-syntax-ns#type10408507.3930.008
cell linerdf-schema#label106030413.3270.008description104208913.0980.00822-rdf-syntax-ns#type83387810.4810.006
chemical compounddescription2475395627.1340.18722-rdf-syntax-ns#type1066060211.6860.081ontology#rank1048451911.4930.079
church building22-rdf-syntax-ns#type254171615.110.019ontology#rank225678613.4160.017prov#wasDerivedFrom9725995.7820.007
clinical trial22-rdf-syntax-ns#type445373516.060.034ontology#rank445364216.060.034minimum age15952525.7520.012
collection22-rdf-syntax-ns#type520624115.9360.039ontology#rank520455715.930.039prov#wasDerivedFrom21506466.5830.016
encyclopedia articledescription1196861535.8630.09122-rdf-syntax-ns#type33026369.8960.025ontology#rank29133708.730.022
family namedescription5988556731.9730.453rdf-schema#label5769216330.8020.437core#altLabel5137767827.4310.389
film22-rdf-syntax-ns#type728488815.4420.055ontology#rank648018413.7360.049prov#wasDerivedFrom35976457.6260.027
geneprov#wasDerivedFrom1632840113.3380.12422-rdf-syntax-ns#type1604650713.1080.121ontology#rank1599281013.0640.121
group of stereoisomers22-rdf-syntax-ns#type87482714.9720.007ontology#rank87131314.9110.007found in taxon61220410.4770.005
hamlet22-rdf-syntax-ns#type122241813.5620.009ontology#rank92436210.2550.007prov#wasDerivedFrom8138089.0290.006
hill22-rdf-syntax-ns#type221505012.8570.017ontology#rank185731210.7810.014GeoNames ID15682249.1030.012
house22-rdf-syntax-ns#type189345515.1860.014ontology#rank182528214.6390.014coordinate location7464165.9860.006
human22-rdf-syntax-ns#type12721043113.3270.963ontology#rank11522647312.0710.872rdf-schema#label825718738.650.625
human settlement22-rdf-syntax-ns#type521490713.1720.039ontology#rank38401669.70.029description32228568.140.024
island22-rdf-syntax-ns#type128229312.9720.01ontology#rank9582459.6940.007description8976319.080.007
item of collection or exhibition22-rdf-syntax-ns#type182131116.9690.014ontology#rank182043616.9610.014part of7122096.6360.005
lakedescription240607413.3280.01822-rdf-syntax-ns#type219989412.1860.017ontology#rank181341510.0450.014
literary work22-rdf-syntax-ns#type147896514.7170.011ontology#rank125261812.4640.009instance of6170936.1410.005
mountaindescription436783613.1010.03322-rdf-syntax-ns#type404647312.1370.031ontology#rank32382619.7130.025
paintingdescription1031141418.1640.07822-rdf-syntax-ns#type684840912.0640.052ontology#rank679119911.9630.051
position22-rdf-syntax-ns#type61668513.0640.005ontology#rank58002212.2870.004rdf-schema#label54432311.5310.004
primary school22-rdf-syntax-ns#type125227714.0450.009ontology#rank123638613.8660.009prov#wasDerivedFrom100876211.3140.008
prime numberdescription79571215.3350.006ontology#rank64458312.4230.00522-rdf-syntax-ns#type52696710.1560.004
print22-rdf-syntax-ns#type142556314.6960.011ontology#rank142519914.6930.011prov#wasDerivedFrom107830911.1170.008
proteinprov#wasDerivedFrom1242716514.0450.09422-rdf-syntax-ns#type1136805712.8480.086ontology#rank1135756712.8360.086
riverdescription365103712.6620.02822-rdf-syntax-ns#type356731012.3720.027ontology#rank28293169.8130.021
scholarly articledescription132417749420.2510.025cites work85361199613.0546.462ontology#rank79654885112.1816.03
sports season22-rdf-syntax-ns#type157273114.7070.012ontology#rank115672010.8170.009instance of4961134.6390.004
stream22-rdf-syntax-ns#type87397813.1340.007ontology#rank73496411.0450.006GeoNames ID5876998.8320.004
street22-rdf-syntax-ns#type423671114.0050.032ontology#rank409694613.5430.031description22568167.460.017
taxonrdf-schema#label6984084818.9820.529description4530880812.3150.34322-rdf-syntax-ns#type4098824411.140.31
version, edition, or translation22-rdf-syntax-ns#type159171414.4730.012ontology#rank153893713.9930.012prov#wasDerivedFrom7128526.4820.005
village22-rdf-syntax-ns#type330796112.4910.025description321284412.1320.024ontology#rank23041458.70.017
village in Indiadescription233672215.190.018ontology#rank14674509.5390.01122-rdf-syntax-ns#type13922249.050.011
village-level division in Chinadescription2471763647.8880.187rdf-schema#label47200639.1450.03622-rdf-syntax-ns#type35331176.8450.027
watercourse22-rdf-syntax-ns#type125637812.4640.01ontology#rank103996710.3170.008description100937710.0130.008

Predicates across subgraphs

From the predicates point of view: how widely are they used? We already know some predicates are used in 1 subgraph. What about the others? Following is a diagram showing the usage of the 60 most used predicates in Wikidata across various subgraphs. Note that the usage were calculated only for the top 50 subgraphs, which account for ~85% of Wikidata. So this should give us an idea of the high use cases of each of these predicates. The rest can be considered a long tail to each of these plots.

The x-axis shows the rank of the subgraph instead of the name to save space. The rank-name mapping can be found in #Table of top 50 subgraph information. The figures are large but can be clicked and zoomed in without loss of resolution for better viewing.

Predicate usage in log scale

Below is the same image in logarithmic scale to show the wide differences in usage counts across subgraphs where applicable.

Top usage

As mentioned above, we can isolate some predicates that are used >=99% in a particular subgraph. Some are even used 100% of the times in that particular subgraph. The following graph shows the distribution of the highest percentage usage in a subgraph a predicate has.

For the predicates that are used a lot in a particular subgraph, it is possible that it is used a very small number of times in other subgraphs (second max usage count is low) or it is also used a lot in other subgraphs (second max usage count is quite high). In short: we also want to look at second max percentages.

Here is an interactive plot showing the max percent, second max percent, color coded with the number of subgraphs the predicate is used in: predicate_usage

Rate of growth of subgraphs

Here is an interactive chart showing the growth of the top 50 subgraphs over a period of one month: subgraph_growth_rate

Subgraph Connectivity

Wikidata is very inter-connected. Although some analysis is possible for individual graphs, it is also important to look into how connected these subgraphs are. In fact, Wikidata is a whole graph in and of itself. For the purposes of analysis, we defined subgraphs, otherwise, Wikidata (as of now) does not distinguish among these subgraphs in ways.

To define connectivity among subgraphs, we consider not only if they are directly connected, but also if they share some properties and items. These components of connectivity are described below. A visualization was created to show the strength of this connectivity between subgraphs here: wikidata_graph. This also shows further information about the subgraphs themselves and what connects them.

Through items

Items in Wikidata can be instance of (P31) multiple entities. If an item is P31 mountain and also P31 hill, we can assume mountains and hills are closely related. Following this assumption, we find the number of items that each pair of subgraph has in common. This helps us find similar subgraphs in Wikidata. A 50 X 50 table containing the number of items each pair of subgraph has in common is available here: subgraph_pair_items.csv. This can also be seen as an information on the edges in the subgraph visualization linked above.

Out of the ~80M items that fall under the top 50 subgraphs:

  • 40,232 items are instance of 2 entities (in the top 50)
  • 57 items are instance of 3 entities (in the top 50)
  • And the rest are instance of only 1 entity
  • There are examples of items that are instance of more than 3 entities, but not all of those entities are part of the top 50 subgraphs.

Following is a list of the subgraph pairs that have the most common items. The full list is given in nonzero_subgraph_pair_detail.csv. While most of the pairs seem reasonable, such as mountain-hill and river-watercourse, some pairs seem odd. This can also be confirmed by the small number of items the two subgraphs have in common. For example, it is odd for the same item to be a village and a river, or a human and a scholarly article, especially since out of the thousands of items these subgraphs have, only 6-10 items are shared. This list can be used as a guide to solve some of the errors (or check if they in fact are errors) in Wikidata.

Subgraph pairs with the most number of common items
subgraph1subgraph2#of items in subgraph1#of items in subgraph2#of shared items%of subgraph1 items shared%of subgraph2 items shared
hillmountain3272775255533710211.347.06
riverwatercourse399552174620149723.758.57
hamletvillage11818827484052824.471.92
hamlethuman settlement11818856395831202.640.55
human settlementvillage56395827484029860.531.09
church buildingarchitectural structure21129114595726221.241.8
riverstream39955212485322040.551.77
version, edition, or translationliterary work15748616486013040.830.79
buildingarchitectural structure2659251459579460.360.65
buildinghouse2659251977369420.350.48

Through properties

Some properties can be used across Wikidata, while others are exclusive to some types of items. We get an idea about predicate usage in #Predicates across subgraphs section. Finding pairs of subgraphs that use a lot of the same properties forms a connection between them. If a pair of subgraphs has a lot of properties in common, it is possible for entities to show up in queries that use these properties, or at least the query may touch on those entities. A 50 X 50 table containing the number of predicates each pair of subgraph has in common is available here: subgraph_pair_predicates.csv, and a heatmap for the same is shown below.

Through triples

Another component of subgraph connectivity is direct connection among the triples across subgraphs. For example:

SELECT ?article ?author
WHERE
{
  ?article wdt:P31 wd:Q13442814.
  ?author wdt:P31 wd:Q5.
  ?article wdt:P50 ?author.
}
LIMIT 10

This query contains triple that connects the scholarly article subgraph with the human subgraph through P50, this is because ?article is instance of scholarly article, whereas ?author is instance of human. The connection here is from scholarly article subgraph to human subgraph.

This connection is defined as such: If the object of a triple that belong to subgraph A, is instance of subgraph B, there is a connection between subgraph A and B

Some of the top subgraph pairs with highest number of triple connection are shown below. Note that subgraphs have a lot of connections to themselves but is not shown here. More information about these subgraphs connections can be found in the subgraph visualization: wikidata_graph.

Subgraph pairs with most direct triple connections (directed edges)
From subgraphTo SubgraphTriple count
scholarly articlehuman1813767
proteingene938854
geneprotein937527
humanfamily name321203
filmhuman229953
scholarly articlechemical compound173924
Wikimedia categorytaxon156468
taxonWikimedia category156440
Wikimedia disambiguation pagefamily name131914
family nameWikimedia disambiguation page127352

A 50X50 chart of all the subgraph pairs and number of directed connections (triple from subgraph A to B is different from triples from subgraph B to A) between them can be found here: subgraph_pair_triple_connections.csv. A logarithmic scale heatmap of this chart is shown below.