我有以下包含子选择的 SPARQL 查询。数据包含多个图表,我想知道值的来源?b
和?m
来源:
select ?b, ?m, ?g1
where {
{
select ?o1, ?o2, ?e
where{
graph ?g{
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_infector_pid> ?o1.
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_infectee_pid> ?o2.
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_iteration> '0'^^xsd:decimal.
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_exposureday> ?e.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_pid1> ?o1.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_pid2> ?o2.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_acttype1> '5'^^xsd:decimal.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_acttype2> '5'^^xsd:decimal
}
}ORDER BY ASC(?e) LIMIT 1
}
{
graph ?g1 {
?b <http://ndssl.bi.vt.edu/chicago/vocab/getInfectedBy> ?o1.
?m <http://ndssl.bi.vt.edu/chicago/vocab/getInfectedBy>* ?b.
}
}
}
第二个图形模式包含传递属性路径,查询提供以下正确结果:
b m g1
----------------------------------------------------- ----------------------------------------------------- -------------------------------------------------------
<http://ndssl.bi.vt.edu/chicago/person/pid#446734805> <http://ndssl.bi.vt.edu/chicago/person/pid#446753456> <http://ndssl.bi.vt.edu/chicago/dendrogram/replicate1/>
但是,我想查看中间节点并计算传递关系的路径长度。如果我graph ?g1
从查询中删除,那么它会显示如下中间节点信息:
b m
--------------------------------------------------- ---------------------------------------------------
http://ndssl.bi.vt.edu/chicago/person/pid#446718746 http://ndssl.bi.vt.edu/chicago/person/pid#446718746
http://ndssl.bi.vt.edu/chicago/person/pid#446734805 http://ndssl.bi.vt.edu/chicago/person/pid#446734805
http://ndssl.bi.vt.edu/chicago/person/pid#446734805 http://ndssl.bi.vt.edu/chicago/person/pid#446753456
查询的目的是找出匹配的图形名称?b
和?m
。因此,我想使用graph ?g1
. 是否可以通过保留graph
关键字来显示中间节点?我正在使用 Virtuoso。