Is there any possibility to create multigraph?


(Akrillis) #1

Hi!

Is there any possibility to create multigraph?
I mean several edges with the same types and facets but different facets values between 2 nodes.

For example:

Node A -> callTo (dateCreated=1,lastSeen=2) -> Node B
Node A -> callTo (dateCreated=11,lastSeen=22) -> Node B
Node B -> callTo (dateCreated=111,lastSeen=222) -> Node A


(Michel Conrado) #2

If I got it right, sure you can.

PS. But the edges need to be different.


(Akrillis) #3

Ok, but for example subscriber A calls to subscriber B 10 times, so i have to store 10 edges with the same type “callTo” but different facets values, startAt1…startAt10 and duration1…duration10. Is this possible somehow?


(Michel Conrado) #4

To make it “readable” I would recommend you to do a queue of calls.

{
	"set": [{
		"uid": "_:subscriberA",
		"calls": [
		  {
				"uid": "_:call_1",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_2",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_3",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_4",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_5",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_6",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_7",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_8",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_9",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			},
			{
				"uid": "_:call_10",
				"from": "_:subscriberA",
				"to": "_:subscriberB",
				"startAt": "0",
				"duration": "0"
			}
		]
	}]
}

(Akrillis) #6

But “calls” aren’t edges in your example…
In Neo4j i can create as many edges between two nodes as i need


(Michel Conrado) #7

Can you exemplify it?

In Dgraph facets are unique between unique edges. And also, facets aren’t the first-class citizen. Thus making Facet just for trivial usage.

You can have dozens of different edges pointing in any direction. But you gonna have a giant schema tho. My example of “queue” is the best approach.


(Akrillis) #8

I’ve understood your approach for calls, thank you, but i have one more question

Here is my schema

		type call {
			a: string
			b: string
			startAt: dateTime
			duration: int
            status: string
		}

		type redirect {
			a: string
			b: string
			startAt: dateTime
			duration: int
            status: string
		}

		type sms {
			a: string
			b: string
			senAt: dateTime
		}

		type msisdn {
			name: string
			msisdn: string
			callTo: [call]
			redirectTo: [redirect]
			smsTo: [sms]
			correspondToImsi: [imsi]
			correspondToImei: [imei]
		}

		type imsi {
			name: string
			imsi: string
			correspondToMsisdn: [msisdn]
			correspondToImei: [imei]
		}

		type imei {
			name: string
			imei: string
			correspondToMsisdn: [msisdn]
			correspondToImsi: [imsi]
		}

		name: string @index(exact) @upsert .
		msisdn: string @index(term, trigram) @upsert @count .
		imsi: string @index(term, trigram) @upsert @count .
		imei: string @index(term, trigram) @upsert @count .
		correspondToMsisdn: [uid] @reverse @count .
		correspondToImsi: [uid] @reverse @count .
		correspondToImei: [uid] @reverse @count .
		a: string @index(term, trigram) .
		b: string @index(term, trigram) .
		callTo: [uid] @count .
		redirectTo: [uid] @count .
		smsTo: [uid] @count .

and i want to have the following facets on edges between msisdn, imsi and imei:

  1. dateCreated (dateTime) - edge creation time (won’t be changed)
  2. lastSeen (dateTime) - changes every time when system get new information about relation between msisdn, imsi or imei

I don’t understand how to create edge with two facets and update just one of them in the future


(Michel Conrado) #9

You don’t have any DateTime in your schema Types. Set it in the Type Schema (Type System) it doesn’t mean it will be automatically applied to schema Types. You need to set both.

Facets are limited, you need to capture all facets and make the change you need (Thus recreating the Facets). Changing one by one does not work. Because facets are not first-class citizens.


(Akrillis) #10

ok

Another question: I’ve received information about msisdn and imsi and want to save date of first appearance of their relation, but i don’t understand how to do that. Because i often receive same msisdns, imsis and imeis and use upsert procedure to create them and i have to recreate “dateCreated” in every upsert. Is there any possibility to set property only one time?


(Mike) #11

Might I suggest looking at this the other way round? A call is the starting node here surely - so a call could involve parties; each party has a redirect capability and other things.

Type Call {
    Parties [Party]
    Start datetime 
    End dateTime
    Status string
    ServiceType int 
}

Then you can simply insert a new call node with all parties involved. Party being a point in time collection of links - an entity that can then hold the device UIDs, subscriber UIDs, your redirect data and any other metadata available at the time (geolocation, cell ID etc) too.

This also allows you to resolve multi-party calls and other services too. So a call might actually represent an “event” - call, message or other thing - hence suggesting a servicetype field.