Updated on 2023-11-13 GMT+08:00

Dynamic Graph

In most real-life problems, entities and relationships change over time (such as disease transmission networks and transaction networks). The time sequence and changing information greatly affect the results. To predict these results, we use dynamic graphs to model, store, and analyze the dynamic data.

Figure 1 Dynamic graphs

This section mainly describes the data format of dynamic graphs. For details about operations related to these graphs, see Creating Dynamic Graphs and Using Dynamic Graphs.

Data Model

A general property graph is a directed graph consisting of vertices, edges, labels, and properties.

A dynamic graph evolves over time. From static to dynamic, there are spatio-temporal graphs (STGs), discrete-time dynamic graphs (DTDGs), and continuous-time dynamic graphs (CTDGs) as shown in dynamic graphs. CTDGs are dynamic graphs that store more details about the vertices and edges.

GES allows you to create CTDGs. The following is an example.

Assume that a graph has three vertices: Vivian, P1, and P2, and three edges: (Vivian, P1), (Vivian, P2), and (Vivian, Vivian). There are two vertex types (lables): Person and Place, and relationship types (label): Visited and Diagnosed. The timestamp [startTime, endTime] indicates the duration of an event. For example, (Vivian, P1) indicates that Vivian visited P1 during 2021-11-21 12:05:21 to 2021-11-21 14:00:00, and (Vivian, Vivian) indicates that Vivian was infected with COVID-19 during 2021-11-25 23:00:00 to 2021-12-04 08:00:00. (Note: The vertex state changed, and the edge that starts and ends with this vertex represents this event.)

Figure 2 Example data model

Metadata of Dynamic Graphs

Timestamps are important features of dynamic graphs. To describe dynamic graph data, you need to define timestamp-related properties such as startTime and endTime in metadata.

Note that startTime and endTime dynamic graph properties and are related to the life cycle of vertices and edges in the graph. The type must be date or long. The following is an example:
<PMML>
  <labels>
    <label name="Person">
      <properties>
        <property dataType="long" name="startTime" cardinality="single"/>
        <property dataType="long" name="endTime" cardinality="single"/>
        <property dataType="string" name="name" cardinality="single"/>
        <property dataType="int" name="age" cardinality="single"/>
        <property dataType="string" name="gender" cardinality="single"/>
      </properties>
    </label>
    <label name="Place">
      <properties>
        <property dataType="string" name="type" cardinality="single"/>
        <property dataType="string" name="address" cardinality="single"/>
        <property dataType="float" name="longitude" cardinality="single"/>
        <property dataType="float" name="latitude" cardinality="single"/>
      </properties>
    </label>
    <label name="Visited">
      <properties>
        <property dataType="long" name="startTime" cardinality="single"/>
        <property dataType="long" name="endTime" cardinality="single"/>
      </properties>
    </label>
    <label name="Dignosed">
      <properties>
        <property dataType="long" name="startTime" cardinality="single"/>
        <property dataType="long" name="endTime" cardinality="single"/>
        <property dataType="string" name="risk" cardinality="single"/>
      </properties>
    </label>
  </labels>
</PMML>

Vertices of Dynamic Graphs

  • Dynamic vertex

    For dynamic graphs, each line of the vertex file contains the data of a vertex. id uniquely identifies vertex data, startTime indicates the start time of the vertex lifecycle, and endTime indicates the end time of the vertex lifecycle.

    id,label,startTime,endTime,property1,property2...

    The following is an example:

    Vivian,Person,1991-02-03 08:00:00,9999-12-31 24:00:00,Vivian,F, 25-34

  • Static vertex

    A vertex without specified startTime and endTime is a static vertex.

    id,label,property1,property2...

    The following is an example for static vertex:

    Vivian,Person,Vivian,F,25-34

    P1,Place,residentialArea,xxxxxx,114.001494,22.554249

    P2,Place,publicArea,xxxxxx,114.074367,22.53492

  • Note

    If a vertex changes over time in its lifecycle, for example, the health status information of a person changes in a certain period, the changes can be modeled as an edge. The edge data is stored in a line of the edge file, representing status changes of the vertex.

    id,id,label,startTime,endTime,property...

    The following is an example:

    Vivian,Vivian,Diagnosed,2021-11-25 23:00:00,2021-12-04 08:00:00,Covid-9

Edges of Dynamic Graphs

  • Dynamic edge

    The following example shows the data of an edge in a dynamic graph. Each line in the edge file contains the data of an edge. id 1 and id 2 indicate the IDs of the start and end vertices of an edge, respectively. startTime indicates the start time of the edge lifecycle, and endTime indicates the end time of the edge lifecycle.

    id 1, id 2, label, startTime, endTime, property 1, property 2, …

    The following is an example:

    Vivian,P1,Visited,2021-11-21 12:05:21,2021-11-21 14:00:00

    Vivian,P2,Visited,2021-11-21 16:33:18,2021-11-21 19:51:00

  • Static edge

    An edge without the start time and end time is a static edge.

    id 1, id 2, label, property 1, property 2, …

Vertex and Edge Data File

  • Vertex data file

    Each line in the file indicates a dynamic/static vertex. You can use more than one vertex file.

    Vivian,Person,Vivian,F,25-34

    P1,Place,residentialArea,xxxxxx,114.001494,22.554249

    P2,Place,publicArea,xxxxxx,114.074367,22.53492

  • Edge data file

    Each line in the file indicates a dynamic/static edge. You can use more than one edge file.

    Vivian,P1,Visited,2021-11-21 12:05:21,2021-11-21 14:00:00

    Vivian,P2,Visited,2021-11-21 16:33:18,2021-11-21 19:51:00