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 ] .