Fork me on GitHub
#asami
<
2021-04-26
>
kj14:04:12

possibly a stupid question: does asami allow you to associate weights (or other properties) to edges? (Like setting properties on a relationship in Neo4j: (:Person {person_id:'123'})-[:FRIEND {date:'1972-01-01'}]->(m:Person {person_id:'456'}) [I.e. Person 123 and Person 456 have been friends since 1972-01-01] )

quoll17:04:37

If you use the in-memory multi graph then yes

quoll17:04:35

URL scheme is asami:multi:

quoll17:04:28

You can add edges multiple times, or if you use the graph update function on a connection, you can update the graph with another function that lets you set the number more directly

quoll17:04:45

This is done by passing a connection to the function asami.storage/transact-update along with a function that receives a graph and a transaction number to use. That function can then call asami.multi-graph/multi-graph-add e.g.

(storage/transact-update my-connection
  (fn [graph txid]
    (multi-graph/multi-graph-add graph entity attribute value txid weight)))

quoll17:04:23

(The index keeps a count value for edges. It does not store multiple edges)

quoll17:04:19

Cisco was using this specifically to weight edges that were being displayed, so the plotting algorithm could make useful decisions on layout

quoll17:04:52

Oh, sorry @kiran.joshi. I was on my phone and didn’t read the full question about other properties.

quoll17:04:03

For now, multigraphs have weight

quoll17:04:20

Durable storage has allocated an ID for every statement (i.e. each individual edge), and properties can be given to these. BUT… I haven’t exposed it, because I don’t know what the API should look like yet

quoll17:04:45

I thought that this was a decision I could put off for a while longer, because no one had asked for it 🙂

quoll17:04:56

This isn’t an afterthought. It would be slightly cheaper to not have these IDs. But I wanted to support reification on edges, specifically like this, so I built it in

quoll17:04:45

If anyone has ideas on how they want to access this (specifically, by querying), then please let me know.

quoll17:04:34

At this point, the easiest way would be as a 4th element in a pattern in the :where clause. But I’ve been reluctant to do that because that has a completely different meaning in Datomic