../ Data Science
-rw-r--r--aguang6.4 KiB7 min read

Formal Description of Graph Data

1. Graph Data Models

1.1 PGM - Property Graph Model

Property graph model is a kind of formal definition of graph data. In this model, data is reprensented as a directed, attributed multi-graph.

Let's say:

  • O\mathcal{O} is a set of objects.
  • K\mathcal{K} is a set of property keys.
  • L\mathcal{L} is a set of labels.
  • N\mathcal{N} is a set of values.

Then a property graph is a structure (V,E,η,λ,μ)(V, E, \eta, \lambda, \mu) where

  • V⊆OV \subseteq \mathcal{O} is a set of objects, called vertices.
  • E⊆OE \subseteq \mathcal{O} is a set of edges, called edges.
  • η:E→V×V\eta : E \to V \times V is a function assigning each edge to an ordered pair of vertices.
  • λ:V∪E→P(L)\lambda : V \cup E \to \mathcal{P}(\mathcal{L}) is a function assigning each object to a set of labels.
  • μ:(V∪E)×K→N)\mu : (V \cup E) \times \mathcal{K} \to \mathcal{N}) is a function assigning each object and key to a value.

Example.

Here is an example property graph of three people and their relations:

1 1 : Emily : Kiwi occupation = teacher age = 35 2 2 : Grey occupation = student age = 24 1->2 4 : teaches subject = english 3 3 : Bob occupation = self-employed 2->3 5 : knows since = 2019 3->3 6 : worksFor since = 2018

For this example:

  • V={1,2,3}V = \{1, 2, 3\}

  • E={4,5,6}E = \{4, 5, 6\}

  • η=E→V×V\eta = E \to V \times V is:

    objectvertices
    41, 2
    52, 3
    63, 3
  • λ=V∪E→P(L)\lambda = V \cup E \to P(\mathcal{L}) is:

    objectlabels
    1Emily, Kiwi
    2Grey
    3Bog
    4teaches
    5knows
    6worksFor
  • μ=(V∪E)×K→N\mu = (V \cup E) \times \mathcal{K} \to \mathcal{N} is:

    objectkeyvalue
    1occupationteacher
    1age35
    2occupationstudent
    2age25
    3occupationself-employed
    4subjectEnglish
    5since2019
    6since2018

1.2 OPPGM - Objectified Paths Property Graph Model

Based on PGM, if we turn paths into objects, we get objectified paths property graph model (OPPGM).

An OPPGM is a structure (V,E,P,η,δ,λ,μ)(V, E, P, \eta, \delta, \lambda, \mu) where

  • V⊆OV \subseteq \mathcal{O} is a set of objects, called vertices.
  • E⊆OE \subseteq \mathcal{O} is a set of objects, called edges.
  • P⊆OP \subseteq \mathcal{O} is a set of objects, called paths.
  • η:E→V×V\eta : E \to V \times V is a function assigning each edge to a pair of vertices.
  • δ:P→∪n>=0En\delta : P \to \cup_{n >= 0} E^n is a function assgining each path to a sequence of edges.
  • λ:V∪E∪P→P(L)\lambda : V \cup E \cup P \to \mathcal{P}(\mathcal{L}) is a function assigning each object to a set of labels.
  • μ:(V∪E∪P)×K→N\mu : (V \cup E \cup P) \times \mathcal{K} \to \mathcal{N} is a function assigning each object and key to a value.

1.3 OSPGM - Objectified Subgraph PGM

Based on PGM, if we turn subgraphs into objects, we get objectified subgraph PGM (OSPGM).

An OSPGM is a structure (V,E,G,η,γ,λ,μ)(V, E, G, \eta, \gamma, \lambda, \mu) where

  • V⊆OV \subseteq \mathcal{O} is a set of objects, called vertices.
  • E⊆OE \subseteq \mathcal{O} is a set of objects, called edges.
  • G⊆OG \subseteq \mathcal{O} is a set of objects, called subgraphs.
  • η:E→V×V\eta : E \to V \times V is a function assigning each edge to a pair of vertices.
  • γ:G→P(V)×P(E)\gamma : G \to \mathcal{P}(V) \times \mathcal{P}(E) is a function assigning every subgraph to a pair of vetex set and edge set.
  • λ:V∪E∪G→P(L)\lambda : V \cup E \cup G \to \mathcal{P}(\mathcal{L}) is a function assigning each object to a set of labels.
  • μ:(V∪E∪G)×K→N\mu : (V \cup E \cup G) \times \mathcal{K} \to \mathcal{N} is a function assigning each object and key to a value.

1.4 HVPGM - Hypervetex PGM

Based on PGM, if we turn subgraphs into vertices, we get hypervetex PGM (HVPGM).

An HVPGM is a structure (V,E,η,γ,λ,μ)(V, E, \eta, \gamma, \lambda, \mu) where

  • V⊆OV \subseteq \mathcal{O} is a set of objects, called vertices.
  • E⊆OE \subseteq \mathcal{O} is a set of objects, called edges.
  • η:E→V×V\eta : E \to V \times V is a function assigning each edge to a pair of vertices.
  • γ:V→P(V)×P(E)\gamma : V \to \mathcal{P}(V) \times \mathcal{P}(E) is a function assigning every subgraph to a pair of vetex set and edge set.
  • λ:V∪E→P(L)\lambda : V \cup E \to \mathcal{P}(\mathcal{L}) is a function assigning each object to a set of labels.
  • μ:(V∪E)×K→N\mu : (V \cup E) \times \mathcal{K} \to \mathcal{N} is a function assigning each object and key to a value.

1.5 HEPGM - Hyper Edge Property Graph Model

Based on HVPGM, if a edge can link to any non-empty sequence of vertices without repetitions (not only 2 vertices), we get hyper edge property graph model (HEPGM).

Ans HEPGM is a structure (V,E,η,γ,λ,μ)(V, E, \eta, \gamma, \lambda, \mu) where

  • V⊆OV \subseteq \mathcal{O} is a set of objects, called vertices.
  • E⊆OE \subseteq \mathcal{O} is a set of objects, called edges.
  • η:E→∪X∈P(V)−∅[π(1),...,π(∣X∣)]\eta : E \to \cup_{X \in \mathcal{P}(V) - \empty} {[\pi(1),...,\pi(|X|)]} is a function assigning each edge to a non-empty sequence of vertices without repetitions.
  • γ:V→P(V)×P(E)\gamma : V \to \mathcal{P}(V) \times \mathcal{P}(E) is a function assigning every subgraph to a pair of vetex set and edge set.
  • λ:V∪E→P(L)\lambda : V \cup E \to \mathcal{P}(\mathcal{L}) is a function assigning each object to a set of labels.
  • μ:(V∪E)×K→N\mu : (V \cup E) \times \mathcal{K} \to \mathcal{N} is a function assigning each object and key to a value.

2. Graph Data Queries

2.1 Regular Path Queries

For any property graph G=(V,E,η,λ,μ)G = (V, E, \eta, \lambda, \mu), the regular path queries (PRQ) over GG are recursively generated as follows:

  • ∀a∈L,a∈PRQ\forall a \in \mathcal{L}, a \in \text{PRQ}
  • ∀e∈PRQ,(e)−∈PRQ\forall e \in \text{PRQ}, (e)^- \in \text{PRQ}
  • ∀e∈PRQ,(e)+∈PRQ\forall e \in \text{PRQ}, (e)^+ \in \text{PRQ}
  • ∀e,f∈PRQ,(e)/(f)∈PRQ\forall e, f \in \text{PRQ}, (e) / (f) \in \text{PRQ}
  • ∀e,f∈PRQ,(e)+(f)∈PRQ\forall e, f \in \text{PRQ}, (e) + (f) \in \text{PRQ}

Let's say [[g]]G⊆V×V[[g]]_G \subseteq V \times V is the result of query g∈PRQg \in \text{PRQ}, then:

  • ∀g=a∈L,[[g]]G={(s,t)∣∃e∈E,η(e)=(s,t)∧a∈λ(e)}\forall g = a \in \mathcal{L}, [[g]]_G = \{(s, t) \mid \exist e \in E, \eta(e) = (s, t) \land a \in \lambda(e)\}
  • ∀g=(e)−∈PRQ,[[g]]G={(t,s)∣(s,t)∈[[e]]G}\forall g = (e)^- \in \text{PRQ}, [[g]]_G = \{(t, s) \mid (s, t) \in [[e]]_G\}
  • ∀g=(e)+∈PRQ,[[g]]G=transitive closure for relation[[e]]G\forall g = (e)^+ \in \text{PRQ}, [[g]]_G = \text{transitive closure for relation} [[e]]_G
  • ∀g=(e)/(f)∈PRQ,[[g]]G={(s,t)∣∃μ∈V,(s,u)∈[[e]]G∧(u,t)∈[[f]]G}\forall g = (e) / (f) \in \text{PRQ}, [[g]]_G = \{(s, t) \mid \exist \mu \in V, (s, u) \in [[e]]_G \land (u, t) \in [[f]]_G\}
  • ∀g=(e)+(f)∈PRQ,[[g]]G=[[e]]G∪[[f]]G\forall g = (e) + (f) \in \text{PRQ}, [[g]]_G = [[e]]_G \cup [[f]]_G

COMMAND INTERFACE

↑ ↓ navigate · Enter execute · Esc exit · try “whoami”

Loading filesystem…

:help aguang.xyz

A personal website disguised as an operating system.

Ctrl / Cmd + K
Command palette + full-text search
Tab / Shift + Tab
Move between links and controls
Enter
Open a focused link or search result
↑ / ↓ in search
Navigate search results
In a directory filter
Enter/Done or ↓ focuses a result; Esc clears the filter
Esc
Clear a search or close a window