Weights on relationships

107 views
Skip to first unread message

Jorge Boneu

unread,
Feb 10, 2016, 7:29:06 AM2/10/16
to cayley-users
Hi everyone,

Is there any native way to weight the relationships somehow, so that we could then sort based in the best match (equal relationships * weight) 
Does that requirement have a name in all this graphs new theory? 

Or does someone tried something similar were they had to weight relationships using Cayley?
Please any orientation about were to look will also be helpful ;)

Have a good day

Denys Smirnov

unread,
Feb 10, 2016, 10:31:22 AM2/10/16
to cayley-users
Hi Jorge,

There is no way to associate any additional information with relationships (quads) right now. You may consider adding some other relationships that indicates the weight (may require a separate intermediate node). Later on you can use that info to do the sort in Gremlin query, for example.

среда, 10 февраля 2016 г., 14:29:06 UTC+2 пользователь Jorge Boneu написал:

Jorge Boneu

unread,
Feb 14, 2016, 1:31:09 AM2/14/16
to cayley-users
Hi Denys,
Thank you so much, I will try to implement a mechanism for registering weight.
I had one more question based in your answer.
Are relationships also vertex? if so how can I query them?

Thanks everyone

Denys Smirnov

unread,
Feb 14, 2016, 4:19:43 AM2/14/16
to Jorge Boneu, cayley-users
Cayley operates in a terms of nodes and quads/triples instead of vertices and edges. Nodes are just a unique text values. And the predicate in a quad (relationship type) is also considered a node, thus you can query it.

But "vertex" usually refers to a unique node with a set of unique property values in Gremlin/Neo4j world. If you wanted to ask about relationships that have some attached properties, then the answer is the same as for weights - not directly. Let me give an example. Here is a simple relationship:

<alice> <follows> <bob>

You will definitely have multiple people with name "Alice", so you'll need some unique ID for each one:

<alice_123> <name> "Alice"
<alice_123> <follows> <bob_456>

Now, if you want to add a weight or another property to a "follows" relation, you should pick a unique ID for it as well:

<alice_123>  <alice_123-follows-bob_456> <bob_456>
<alice_123-follows-bob_456> <type> <follows>
<alice_123-follows-bob_456> <weight> "14.5"

The second triple is required to be able to traverse any "follows" relations. The query will looks like this for direct example versus example with relation weight:

g.V("<alice_123>").Out("<follows>")
and
g.V("<alice_123>").Out(g.V().Has("<type>","<follows>"))

Am I answered your question?

--
You received this message because you are subscribed to a topic in the Google Groups "cayley-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cayley-users/3OJeHBzf9bc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cayley-users...@googlegroups.com.
To post to this group, send email to cayley...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cayley-users/a560e113-6ff5-4d64-b439-8516f6a3e909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages