Topic/Term Graph - How to weight a predicate/relationship? + Schema Question

Working on a small project of my own, most likely will remain a hobby, it stores Topics that my application layer qualifies following several rules, and once qualified, inserts it in my graph database.

Once that’s done, for that given topic, the application retrieves content from top n pages, wikipedia, amazon, etc… and qualifies a list of Terms (n-grams, where n is between 1 and 5) are related and belong to this given topic.

For each term qualified, the application inserts it in the graph database on its own, and then adds relationships:

  • topic ABC is defined_by term XYZ
  • term XYZ belongs_to topic ABC

Obviously, a very same term can describe several topics with different weights. And also, a topic can be the parent_of, child_of or just related_to another topic. Besides related_to, all relationships should be unidirectional.

So far, my schema is like this:

scalar (
	slug: string @index
	label: string
	context: string
	summary: string
	wordcount: int
	available: int @index
	created: datetime @index
	topic.topic.parent_of: uid
	topic.topic.child_of: uid
	topic.topic.related_to: uid @reverse
	topic.topic.defined_by: uid
	term.term.belongs_to: uid
)

type Topic {
	slug: string
	label: string
	context: string
	summary: string
	available: bool
	created: datetime
	children: Topic
	parents: Topic
	relations: Topic
	vocabulary: Term
}

type Term {
	slug: string
	label: string
	wordcount: int
	created: datetime
	owners: Topic
}

I have a problem, though.

How to weight these relationships (defined_by, belongs_to, related_to)? Is there a way to add a property called ‘weight’ to a predicate/relationship (typed as float)?

Hey @lazharichir,

Sorry couldn’t get to you earlier. We don’t have a way to attach weights to edges. That’s been on my mind for a while, as something we should implement. But, hadn’t come across a good use case to warrant it.

What kind of queries would you run, which could utilize the weights? Would you use these as filters? Or, as a way to sort the nodes at the end of the edge?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.