0

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!

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
user3590127
  • 131
  • 1
  • 4
  • You don't relate classes with object properties, you relate individuals with object properties. Can you give a concrete example of what you're trying to do? If you're trying to "weight" edges, so to speak, that's typically done with a reified relation, since it's really a three-place relation. You're saying that rather than just the binary relation `edgeBetween(x,y)`, you have the ternary relation `edgeBetweenWithWeight(x,y,w)`. There are some common ways to represent relations like that. E.g., see [Defining N-ary Relations on the Semantic Web](http://www.w3.org/TR/swbp-n-aryRelations/). – Joshua Taylor Apr 30 '14 at 20:34

2 Answers2

3

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 ] .
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thanks, this is quite helpful! My target is to develop an ontology where the terms of the ontology should be connected with differently weighted distances. If I have a lot of terms, I will also have a lot of edges, with your approch above, would every edge be treated as a different relation? My Goal was it to define the a relation like connection(A,B,1); conncection(B,C,2)... the conncetion-relations has still the same name or is an instance from a type/class relation. Can I do that with your approach? – user3590127 May 02 '14 at 08:56
  • @user3590127 I'm sorry, but I'm not quite sure what you're asking. You'll need to be clearer about your terminology. In OWL, there are classes, properties, and individuals. Properties relate individuals and individuals belong to classes. If you're trying to say something like "every individual x of class A is related to every individual y of class B with a relation R with weight W," you can do that, but you'll need to be much more specific in your question. – Joshua Taylor May 02 '14 at 15:21
  • I want to define different distances for different individuals, independent from the class they coming from. Suppose Individual A and B and C. A and B are from the same class AB. Individual C is from Class C. The distance from A to C is DIFFERENT from the distance B to C. All I want to have is modeling structure using hierachical classes containing the individuals, but all individuals can have different distances to each other, just like in a distance matrix. – user3590127 May 02 '14 at 17:21
  • 1
    OK, there's no reason that a property P can't related instances of A with instances of A, and also relates instances of B with instances of B. There's no need to have different properties for that. – Joshua Taylor May 02 '14 at 17:43
  • 1) ":edge345 :hasSource :nodeA . :edge345 :hasTarget :nodeB . :edge345 :hasWeight 34 ." Does this mean I have to create a new edge-name for every new edge? 2) Do u know any good visualization tool that shows relations between the individuals (not classes), didn't find it with protege and ontoviz... – user3590127 May 02 '14 at 18:01
  • 1
    `:edge345` isn't a *property*; it's an *individual*. `:hasSource`, `:hasTarget`, and `:hasWeight` are properties. If you write the data in this form, you would need an individual for instance of the relationship. They don't need to be named, though; you could use blank nodes, I suppose: `[ :hasSource ... ]`. Alternatively, you could do it with axioms and not mention the individuals explicitly, by saying, e.g., `nodeA a (^hasSource some ((hasTarget value nodeB) and (hasWeight value 34)))`. – Joshua Taylor May 02 '14 at 18:12
  • 1
    Also note that using annotation properties (as suggested in [loopasam's answer](http://stackoverflow.com/a/23397787/1281433)) also requires extra nodes at the representation layer because of the way that axiom annotations are encoded in RDF. – Joshua Taylor May 02 '14 at 18:13
  • Once you have defined a property, you can use it whenever you make a statement in RDF. You may find a lot of clarification by reviewing [RDF 1.1 Concepts](http://www.w3.org/TR/rdf11-concepts/). – Rob Hall May 05 '14 at 13:31
  • @RobHall Right, but user3590127 does make an important point here: reified relations, using a representation like what we've got here *does* require a new resource for each "instance" of the relation. I'm not sure if that was the question, though, or if it was one about "one relation per each pair of types of individuals that are to be related" (i.e., one per each possible domain and range). – Joshua Taylor May 05 '14 at 14:09
  • It's absolutely the case that I could be mistaken. That ambiguity that you called out to is why I thought to suggest the abstract syntax. If the question _was_ "can I re-use an edge label?", then the abstract syntax would be helpful. If the question boils down to "how do I / how should I reify statements for this problem", then it's definitely less useful. – Rob Hall May 05 '14 at 14:25
0

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>
loopasam
  • 3,027
  • 2
  • 21
  • 22