计算节点之间的路径长度(边缘未知)? [英] Calculate length of path betwen nodes (with unknown edges)?
问题描述
问题是如何在不知道边类型的情况下使用 sparql 查询计算三重存储 (RDF) 中两个节点(概念)之间的距离.本质上,是使用 Dijkstras_algorithm在 Triple Store 中找到两个概念之间的较短路径.
The problem is how to calculate the distance between two nodes (concepts) in a Triple Store (RDF) using sparql queries without know the type of edges. Essencially, is to use Dijkstras_algorithm to find the shorter path between two concepts in a Triple Store.
如果我们知道 egde 的类型是可能的:计算节点之间的路径长度?
It is possible if we know the type of egde: Calculate length of path between nodes?
另一种解决方案是使用类距离(如果概念不是从主类扩展而来的,则不起作用):测量 RDF/OWL 图中类之间的距离
One other solution is to use classes distances(do not work if concepts are not extended from the main classes): Measuring distances among classes in RDF/OWL graphs
找出 http://bioinformatics.ua.pt/coeus/resource/之间的较短距离uniprot_P01008 和 http://bioinformatics.ua.pt/coeus/resource/go_GO:0005576
推荐答案
您可以使用 计算节点之间的路径长度?,但您需要使用通配符而不是特定属性.模式 (<>|!<>)
是一个通配符,因为每个属性要么是 <>
,要么不是.您也可以使用 (:|!:)
,但这仅在您定义了 :
前缀时才有效.(<>|!<>)
将始终有效.举个例子:
You can use the same technique that's used in Calculate length of path between nodes?, but you'll need to use a wildcard instead of a particular property. The pattern (<>|!<>)
is a wildcard, because every property is either <>
or it isn't. You could also use (:|!:)
, but that will only work if you have a :
prefix defined. (<>|!<>)
will always work. Here's an example:
@prefix : <urn:ex:>
:a :p :b .
:b :q :c .
:c :r :d .
:d :s :e .
prefix : <urn:ex:>
select ?start ?end (count(?mid) as ?length) {
?start (<>|!<>)* ?mid .
?mid (<>|!<>)+ ?end .
}
group by ?start ?end
------------------------
| start | end | length |
========================
| :a | :b | 1 |
| :a | :c | 2 |
| :a | :d | 3 |
| :a | :e | 4 |
| :b | :c | 1 |
| :b | :d | 2 |
| :b | :e | 3 |
| :c | :d | 1 |
| :c | :e | 2 |
| :d | :e | 1 |
------------------------
这篇关于计算节点之间的路径长度(边缘未知)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!