Reputation: 131
suppose I would like to represent following graph with node A, B and C in OWL, connections:
A-B d=1
B-C d=2
A-C d=3
E.g., there is an edge from A to B, with distance d=1
I want model these relations in OWL in a way that I want to make clear that all 3 connections are of the type "edge distance" but they do have different values (d=1,2,3) I won't get it done if follow the approach using A,B,C as classes and defining one single Object Property: "edge distance" and assigning different values for the distance-relations.
Or in other words, what is an efficient way to model the graph above in OWL ?
Thank you very much!
Upvotes: 0
Views: 453
Reputation: 85883
First, properties don't relate classes in OWL. Rather, they relate individuals. You can declare domains and ranges of properties, in which case when a use of the property is found, something can be inferred about the type of the subject and the object. If a property P has domain D and range R, it means that when you see a triple x P y
, you can infer that x rdf:type D
and y rdf:type R
.
It sounds like you're trying to represent a property that has an associated weight. This is, strictly speaking, a ternary relation, since you'd want to say something like edgeBetween(source,target,weight). A common way of representing this kind of information in RDF or OWL is to use a new node to represent an instance of the relation, and to relate the three parts to that individual. E.g.,
:edge345 :hasSource :nodeA .
:edge345 :hasTarget :nodeB .
:edge345 :hasWeight 34 .
or even more compactly:
:edge345 :hasSource :nodeA ;
:hasTarget :nodeB ;
:hasWeight 34 .
Since it's often the case that you don't need to be able to identify the instance of the relation so much as just the parts of it, you can use a blank node here, too:
[] :hasSource :nodeA ;
:hasTarget :nodeB ;
:hasWeight 34 .
or
[ :hasSource :nodeA ;
:hasTarget :nodeB ;
:hasWeight 34 ] .
Your graph,
A-B d=1
B-C d=2
A-C d=3
would look something like this:
[ :hasSource :A ; :hasTarget :B ; :hasWeight 1 ] .
[ :hasSource :B ; :hasTarget :C ; :hasWeight 2 ] .
[ :hasSource :A ; :hasTarget :C ; :hasWeight 3 ] .
Upvotes: 3
Reputation: 3146
You could represent it by defining a tiny "network" ontology and by using OWL annotation properties to represent the distance. This solution as some disadvantage (no smart reasoning on annotation properties), but it is relatively simple to understand.
Pseudo-code in Manchester syntax:
# Prefix used for the demo:
Prefix: network: <http://www.example.org/>
# Annotation property that will hold the distance value between two nodes
AnnotationProperty: <network:distance>
# Edges will be modelled with an object property
ObjectProperty: <network:edge>
# We define the concept of "Node" as a class.
Class: <network:Node>
# Two individuals A and B are declared. They represent node instances
Individual: <network:B>
Individual: <network:A>
Facts:
# Annotation of the axiom below (link A -> B)
# with a value for the distance
Annotations: <network:distance> "1"
# The object property linking the node A to the node B
<network:edge> <network:B>
Upvotes: 0