Showing multiple edge from Vertex A to B

Hi,

I have a telecom data of a Person calling or texting another Person. A person may contact another person multiple times. I have a directed Edge from Person to Person. Person - Contact -> Person

The problem is that I have a scenario where P1 calls P2 four(4) times on different dates and times, but I only see one Edge line originating from P1 to P2. The duplicate edge information are not loaded in the Edge. Can anyone please help how to load duplicate Edge entries.

Vertex Person(Phone_Number)

Edge Contacted(From Person, To Person, Contact_Date)

Thank you

1 Like

Hi Khan,

Thanks for your question.

For this type of problem, there are two options.

  1. Create a vertex in between to store the edge attribute. For topology below, if A called B four times (TS1 TS2 TS3 and TS4 are 4 DateTime values).

A – (A-B-TS1)-- B
A – (A-B-TS2)-- B
A – (A-B-TS3)-- B
A – (A-B-TS4)-- B

We can create 6 vertexes and 8 edges. Having (A-B-TS1), (A-B-TS2), (A-B-TS3), (A-B-TS4) stay in between A and B.

To prevent duplicate ID, we can use from vertex ID (A) and to vertex ID (B) as part of the vertex ID in the middle. e.g. we can use the ID “A-B-2019-05-05 09:00” to create vertex (A-B-TS1). Where 2019-05-05 09:00 is the time the phone call happened.

This way it takes two hops to traverse from A to B, along the way you can collect all the info you need.

Pros: fast update, easy to remove an edge, easy to set a filter on the edge.

Cons: consume more memory, take an extra hop to traverse from A to B.

  1. Using global tuple and list type of attribute.

We can add an attribute on the edge under type of list of tuple.

Way of defining tuple:

https://docs.tigergraph.com/dev/gsql-ref/querying/data-types#tuple

Way of defininig list:

https://docs.tigergraph.com/dev/gsql-ref/ddl-and-loading/creating-a-loading-job#loading-a-list-or-set-attribute

This way you can directly access the list attribute to get the value. The way of using list attribute is identical as using ListAccum.

https://docs.tigergraph.com/dev/gsql-ref/querying/accumulators#listaccum

Alternatively, you can also define multiple lists to store different fields. The orders follow the order being loaded.

Cons: slow in updating and retrieving.

Pros: easy in defining the schema, memory saving.

Please let me know if you have further questions.

Thank you Chang for the solution. This sounds good. Can you also help me traverse the contact made in two hops?

Appreciate your response.

Thanks

-Khan