<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Reconstructing Graph Pattern Matches Using SPARQL</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Stephan Mennicke</string-name>
          <email>mennicke@ips.cs.tu-bs.de</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Denis Nagel</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jan-Christoph Kalo</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Niklas Aumann</string-name>
          <email>n.aumanng@tu-bs.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Wolf-Tilo Balke</string-name>
          <email>balkeg@ifis.cs.tu-bs.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institut fur Informationssysteme</institution>
          ,
          <addr-line>TU Braunschweig</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Institut fur Programmierung und Reaktive Systeme</institution>
          ,
          <addr-line>TU Braunschweig</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2017</year>
      </pub-date>
      <abstract>
        <p>Pattern matching is the foundation for handling complex queries to graph databases. Commonly used algorithms stem from the realm of graph isomorphism and simulations, being well understood theoretical frameworks. On the practical side, there are established graph query languages that often allow for a wide variety of query tasks, often even beyond pattern matching. However, very little is known how graph queries from common query languages relate to graph pattern matching relations. In this paper, we propose a study in this respect for SPARQL, the W3C recommendation for querying RDF data. The homomorphic nature of the SPARQL semantics allows for a straight-forward formulation of graph-isomorphic matching. However, the somewhat arti cial nature of these queries motivates the study of sole basic graph patterns, the foundational concept of SPARQL. For basic graph patterns, we show a correspondence to strong simulation, an e cient graph pattern matching relation appreciated for its polynomial bound matches. In consequence, graph query languages are capable of serving as generating frameworks for established graph pattern matching relations.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Graph databases have gained lots of attention due to their popularity in emerging
applications like the Semantic Web, social network analysis, or bio-technology.
These graphs usually provide entity-centric data, in which nodes represent
entities, while the edges model relations between entities. Several graph database
query languages were developed, enabling users to query graph-structured data
in an SQL-like fashion. Most notably, SPARQL is the W3C standard for
querying Semantic Web data, and is also used for a wide range of applications [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
On the foundational side of graph querying, graph pattern matching in terms
of special homomorphisms forms the main in uence. However, to the best of
our knowledge, only little is known on the relationship between commonly used
graph query languages | SPARQL in this paper | and other graph pattern
matching relations that have been researched for decades in conceptual
frameworks. Research in this area led to several complexity results, the development of
directed
wrote
awarded
v3
v4
(a)
      </p>
      <p>
        S.Spielberg
fast algorithms, and insights on the semantics of the respective relations, whose
potential is, in our view, not yet fully exploited in the area of graph database
querying. Lately, some e ort were expended to use graph pattern matching
algorithms for matching relations di erent from classical subgraph isomorphism,
often appreciated due to their advantages in performance over traditional graph
querying languages [
        <xref ref-type="bibr" rid="ref11 ref9">9, 11</xref>
        ].
      </p>
      <p>In this paper, we study the relationship between graph pattern relations and
graph query languages, here exempli ed by SPARQL. Our rst result is best
explained by an example. Imagine a user writing a query to search for the directors
and writers of movies that won an award, see Fig. 1(a). An isomorphic match
to this query is, for instance, the movie Jurassic Park which won an Academy
Award, was written by M. Crichton, and directed by S. Spielberg (cf. Fig. 1(b)).
The same result is achieved by the SPARQL query, depicted in Fig. 2. The rst
part, also called basic graph pattern, comprises variables for the graph pattern
nodes and is arranged as triples representing the edges of the graph pattern. The
lter condition at the end of the pattern ensures that each assignment to the
variables is a bijective one, a necessary condition for graph-isomorphic
matching. Being able to formulate such a query is not a coincidence. We prove, in
Sect. 4, for every graph pattern there is a query returning every subgraph from
a database that is isomorphic to the given pattern. A closer look at the lter
condition raises the question, whether a user would be using such an arti cial
formulation. Removing the lter allows for (possibly unintended) variable
assignments, and may produce answers as depicted in Fig. 1(c). Solely relying on
basic graph patterns yields answers showing a (dual-)simulating character upon
the original graph pattern, being the result of Sect. 5.</p>
      <p>
        We provide partial and complete characterizations of graph pattern matching
by SPARQL, based on basic graph patterns. We observe that dual simulation
cannot be fully characterized, since the matching relation allows for arbitrary
additions to matches, being also matches of the pattern. Strong simulation, an
extension of dual simulation, removes this arbitrariness and is a matching
relation renown for its e cient evaluation and its polynomial bound number of
matches [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. We nd that SPARQL results may be used as building blocks to
obtain all strong simulating matches. In return, strong simulation may also serve
as a pruning method for SPARQL query engines. Sect. 3 provides basic notions.
SELECT
WHERE f ?vv1 d i r e c t e d ?vv3 . ?vv2 w ro t e ?vv3 . ?vv3 awarded ?vv4 .
      </p>
      <p>FILTER ( ?vv1 != ?vv2 &amp;&amp; ?vv1 != ?vv3 &amp;&amp; ?vv1 != ?vv4 &amp;&amp;
?vv2 != ?vv3 &amp;&amp; ?vv2 != ?vv4 &amp;&amp; ?vv3 != ?vv4 ) g
Related work and conclusions are given in Sect. 2 and Sect. 6. Due to space
limitations, full proofs of the theorems are included in the appendix of this paper.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        Graph Pattern Matching is an extensively studied topic in various domains of
computer science [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Its applications range from social network analysis, over
structural analysis of chemical entities to various applications in the database
domain, particularly in graph databases. Recently, emerging applications led to the
trend of graph pattern matching relations, di erent from the canonical though
costly candidate of graph isomorphism, with the goal of reducing structural
requirements of the answer graphs. For example, the idea of simulation for graph
pattern matching has been implemented for di erent graph database tasks [
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1,
3, 2</xref>
        ]. Indeed, experiments have shown advantages of simulation-based matching
relations when analyzing social network patterns, as they o er the possibility to
collapse several nodes into one node and vice versa. Another recent case study
in this respect are so called Exemplar Queries [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], representing an attempt to
enable an easy access to databases without the need of knowing the formal
requirements of a query language. Based on an example graph pattern from the
database (the exemplar), the query process of Exemplar Queries checks for
similarity, e. g., up to strong simulation, between the exemplar and other database
structures, retrieving and ranking them for presentation to the user.
      </p>
      <p>
        Graph Query Languages basically all are founded on the idea of graph
pattern matching (with suitable substitutions) [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. A matching mechanism
common to most of these query languages is (sub-)graph isomorphism [
        <xref ref-type="bibr" rid="ref4 ref8">4, 8</xref>
        ]. Mainly
due to the advances in the eld of Semantic Web, SPARQL has become the
W3C recommendation for querying Semantic Web data, i. e., RDF. A more
detailed introduction to SPARQL follows in the next section. In general, graph
query languages di er greatly with respect to their area of operation. Therefore,
many di erent graph database operations, e. g., subgraph matching or adding
new nodes, are considered, particularly when comparing the expressive power of
di erent graph query languages [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Most languages solely rely on
homomorphic, more speci cally, isomorphic pattern matching, but their connection to
other matching relations is not yet studied extensively. Therefore, here we give
insights into this aspect of graph query languages with respect to SPARQL. The
basic idea however, could also be applied to other graph querying languages, also
relying on the idea of basic graph patterns (e. g., Cypher or Gremlin).
Regarding expressiveness of graph querying languages, in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], the authors describe the
graph query language GraphQL. It is based on a modi ed relational algebra that
uses graph pattern matching for querying. They prove that their graph query
algebra is relationally complete and therefore as expressive as relational algebra.
      </p>
      <p>
        While we focus on graph isomorphism and simulations, the key question
behind this work is not restricted to those relations. Many more comparison
relations are discussed in the literature which may correlate very well with the
semantics of graph query languages. For instance, the linear-time branching-time
spectrum [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] provides several matching relations, under the term comparative
semantics, used w. r. t. di erent aspects of system correctness. It contains
comparative system relations for processes modeled as labeled transition systems,
i. e., edge-labeled directed graphs with a distinct initial state. Most of the
semantics come with a logical characterization in terms of a modal logic equipped with
explicit quanti cation over edges to be traversed. Finding such a
characterization is a common task, as it allows for expressing distinguishing characteristics
of system behaviors in a precise manner. Similar to our subject, these
characterizations express that two systems are equivalent whenever they satisfy the same
logical formulas. In this paper, we try to adjust to the circumstances as imposed
by SPARQL semantics.
      </p>
      <p>
        Variants of graph homomorphism are also studied in the context of graph
databases [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. While the relations in our work always match an edge of a graph
to other edges, as of preserving structure of a graph pattern to a certain extent,
p-homomorphism takes each edge and maps it to paths in the match graph. This
way, a p-homomorphic match graph may show a very di erent structure, being
only loosely coupled with the graph pattern. Instead, p-homomorphic matching
relies on a metric of node similarity.
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Preliminaries</title>
      <p>In this section, we de ne graphs, graph databases complemented by the general
concept of graph pattern matching. Furthermore, we introduce an algebra of
SPARQL.</p>
      <p>A ( -)labeled directed graph is a triple G = (V; ; E), where V is a nite
set of nodes, a nite alphabet, and E V V a labeled edge relation.
We represent an edge (v; a; v0) 2 E by v a! v0. Labeled directed graphs range
over by G; G1; G2; P with node sets V; V1; V2; VP , a xed alphabet common to
all graphs, and edge relations E; E1; E2; EP with respective notations !; !1
; !2; !P . A graph G1 is a subgraph of a graph G2, denoted G1 v G2, i
V1 V2 and E1 E2 \ (V1 V1). Two graphs G1 and G2 are isomorphic,
iwf rainttdenonGly1 i=f G(v2), i a!th2er(evi0s).a biisjeccatlilveed faunncistoiomnorp:hVis1m!beVt2weseunchGt1haatndv Ga!2. 1Fovr0
two nodes v; v0 of a graph G, we de ne the distance dist G(v; v0) to be the length
of the shortest undirected path from v to v0. If there is no path between v and v0,
dist G(v; v0) = 1. However, we are interested in connected graphs throughout the
rest of the paper, i. e., for every two nodes v; v0, dist G(v; v0) 6= 1. The diameter
of a graph G with node set V , denoted dia(G), is the greatest distance between
nodes in this graph, i. e., dia(G) := maxfdist G(v; v0) j v; v0 2 V g.</p>
      <p>Graph databases store objects from a countable universe O together with
attributes over the objects as either relations between objects or properties of
objects. As an example, consider an isFriendOf relation between objects
referring to persons who are friends in social networks. Properties of objects are
expressed as assignments of concrete data values, also called literals, from a
usually in nite domain L, to an object, e. g., the age of a person as a positive
integer. Inspired by the treatment of literals in RDF, objects as well as literals
are represented as nodes in a graph database. Relation symbols and property
symbols stem from a nite set, here . A graph database is a directed labeled
graph DB = (V; ; E) with a nite set of database objects V O [ L.</p>
      <p>A graph pattern is a connected graph P = (VP ; ; EP ). A subgraph G of a
graph database DB is an isomorphic match of P (in DB) i P = G. By JP KD=B
we denote the set of all isomorphic matches of P .</p>
      <p>
        Since SPARQL aims at querying RDF-stored data, the basic building blocks
of the query language are triples of the form (s; p; o). Subjects (s) refer to objects
in O or variables being assigned by actual database objects during the querying
process. Objects (o) may further be associated with literals from L. Predicates
(p) are thought of as the relation and property symbols in gluing together
subjects with objects. Variables are place-holders for actual objects or literals
as present in concrete databases. The result of a SPARQL query process is
an assignment of objects and literals to the variables mentioned in a query
expression. We denote the set of all variables by V. Notation and semantics are
based on [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
      <p>Sets of such (s; p; o)-triples are called basic graph patterns (BGP), which
we will assume to be graphs. For every BGP B = f(s1; p1; o1); : : : ; (sk; pk; ok)g
(k 0) where si 2 O [ V, pi 2 , and oi 2 O [ L [ V (i = 1; : : : ; k), the
associated graph is (VB; ; B) such that VB = fs1; : : : ; sk; o1; : : : ; okg. Notice
that the nodes in the graph may also be variables. In fact, from the next section
on, we employ BGPs in which all nodes are variables. In this paper, BGP B and
its graph representation are used interchangeably. By vars(B) we denote the set
of all variables occurring in B.</p>
      <p>The semantics of SPARQL BGPs B, and henceforth of SPARQL queries Q,
is given in terms of assignments of objects and literals to variables in B (Q,
respectively). An assignment is a partial function : V ! (O [ L). By (B) we
reference the graph where each variable node v 2 vars(B) is replaced by (v). We
de ne dom( ) := fv 2 V j (v) is de nedg. An assignment is valid w. r. t. B
and a graph database DB i (a) dom( ) = vars(B) and (b) (B) is a subgraph of
DB. Thus, is a graph homomorphism. The set of all valid assignments w. r. t. B
and a graph database DB forms the foundation of the SPARQL query semantics.
We denote this set by JBKDB.</p>
      <p>
        The second concept of SPARQL we use is that of lter conditions, also called
built-in conditions. Filters are used to further restrict the set of (valid)
assignments of a SPARQL query. Thereby, we may check for equality (=) or inequality
(&lt;; ; ; &gt;) of variable assignments, objects, and literals. The usual
propositional connectives (^; _; :) are used to build complex constraints. For a full
list of features we refer to the W3C recommendation report [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]. We
denote by j= ' that assignment satis es lter condition '. Let Q be any
SPARQL query, e. g., Q = B for a BGP B, and ' a lter condition. Then
Q filter ' is a SPARQL query. The semantics is given recursively in terms of
the assignments from JQKDB such that every assignment conforms to '. Thus,
JQ filter 'KDB := f 2 JQKDB j j= 'g.
      </p>
      <p>Throughout the paper, we make use of BGPs adjoint with lter
conditions. The last SPARQL concept we need throughout Sect. 5 is that of a
join of two queries. Q1 and Q2 represents the join of Q1 and Q2. Given two
assignments i 2 JQiKDB (i = 1; 2). Then they are compatible if for every
v 2 dom( 1) \ dom( 2), 1(v) = 2(v). Compatible assignments may be joined,
thus, JQ1 and Q2KDB := f 1 [ 2 j i 2 JQiKDB are compatible g. The remaining
operations of union and optional queries are not needed in this paper.</p>
      <p>Next, we show that for every graph pattern P , there is a SPARQL query QP
that uses a BGP and a speci c lter condition to obtain all graph-isomorphic
matches of P from a database DB. Please note that we assume graphs to be
loop-free, throughout the paper, i. e., for each edge v1 a! v2, v1 6= v2.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Querying like Graph Isomorphism</title>
      <p>A graph pattern P gives rise to a canonical BGP. In order to characterize
isomorphic matches of P from some database DB, we need to adapt the nodes of P
to obtain the possibility of arbitrary assignments of database objects/literals to
the nodes of P . In SPARQL terms, this adaptation is performed by exchanging
each node by a variable. Fig. 2 gives an example conversion in the where-clause,
excluding the lter condition.</p>
      <p>De nition 1. Let P = (VP ; ; EP ) be a graph pattern. De ne : VP ! V such
that (v) := vv. The BGP of P is de ned as the graph P^ := (V^P ; ; E^P ) such
that V^P = f (v) j v 2 VP g and ( (v); a; (v0)) 2 E^P i (v; a; v0) 2 EP .
From a graph-theoretic perspective, it directly follows that each graph pattern
P is isomorphic to its BGP P^ by isomorphism . Every assignment 2 JP^KDB
is a homomorphism, but it is not guaranteed that each graph (P^) is isomorphic
to P . We enforce bijectivity of by adding a lter condition checking that for
each two distinct nodes v; v0 2 V^P , assigns di erent objects from the database.
The P -query for isomorphism is Q=(P ) := P^ filter 'P .</p>
      <p>De nition 2. Let P be a graph pattern with set of nodes VP = fv1; v2; : : : ; vng.
De ne a lter condition for P alongside (Def. 1) as 'P = Vi&lt;j (vi) 6= (vj ).
Reconsider the query given in Fig. 2 as an example query for isomorphism. We
now show that the assignments of a P -query for isomorphism are equivalent to
the set of all isomorphic matches w. r. t. P .
Batman
awarded</p>
      <p>J.V.Heart</p>
      <p>wrote</p>
      <p>
        Dracula
Theorem 1. Let DB be a graph database and P a graph pattern. Then G 2
JP KD=B if and only if there is an assignment 2 JQ=(P )KDB such that (P^) = G.
The proof exploits that assignments from respective queries already are
isomorphisms. This means that by using BGPs and a speci c lter condition, we
reach the same expressive power as isomorphic graph pattern matching. In a way,
Theorem 1 states that SPARQL is complete w. r. t. graph-isomorphic matching.
Graph isomorphism is among the strongest similarity-based matching relations
between graphs. Reducing the constructed SPARQL query in this section to only
the BGP yields a similar result between SPARQL and graph homomorphism,
since a valid assignment amounts to a graph homomorphism. However, as we
will see throughout the next section, BGPs themselves show an interesting
correspondence to graph pattern matching by similarity, or more speci cally, strong
simulation. Strong simulation is renown for its e cient evaluation, compared to
isomorphic matching, and its polynomial bound on the number of matches [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
5
      </p>
    </sec>
    <sec id="sec-5">
      <title>Basic Graph Patterns Query for Simulations</title>
      <p>
        In this section, we rst show that every valid assignment of a BGP P^ corresponds
to a so-called dual simulating match of the underlying graph pattern P .
Thereupon, we argue that there is no reasonable way to capture all dual simulating
matches by a single SPARQL query, since a match may be extended arbitrarily,
even by database relations that are not mentioned by pattern P . The notion
of strong simulation extends dual simulation by restricting (1) the size of the
matches by the diameter of the pattern and (2) all occurring nodes and edges to
match nodes and edges in the pattern. We show this restriction to be su cient
to prove the existence of a SPARQL query that captures all strong simulating
matches. We introduce the necessary notions as needed.
Simulations stem from studies of (concurrent) system behavior [
        <xref ref-type="bibr" rid="ref10 ref6">10, 6</xref>
        ]. Intuitively,
system 2 simulates system 1 if whatever action system 1 performs, system 2 is
capable of mimicking this behavior. When we look at graphs, the notion carries
over in the sense that we assume the nodes of the graphs to play the role of states
and the labels on edges to represent the actions. We continue the introductory
example (cf. Fig. 1). Considering the graph pattern P of Fig. 1(a), the graph in
Fig. 3(a) is a simulating match of P. Starting by node v1, P may only perform the
actions, as represented by labeled edges 'directed' and 'awarded', in this order.
Alternatively, the graph may also perform the sequence 'wrote' and 'awarded'
when starting in v2 or just 'awarded' when starting in v3. Identical actions in
the same order may be performed in the match graph. Therefore, it is indeed
a simulating match of P . Formally, a simulation is a binary relation over the
nodes of the respective graphs such that each node of the simulated graph is
actually simulated in the above-mentioned sense. A dual simulation extends the
notion of simulation in such a way that it also looks at actions going backwards
from a simulated node. While Fig. 3(a) represents a simulating match for P , it
is not a dual-simulating match. This is because the pattern may go backwards
from v4 via 'awarded' and then face the choice to go for 'directed' or 'wrote',
which is not possible in Fig. 3(a). Fig. 3(b), on the other hand, is a valid
dualsimulating match. In the study of concurrent systems, dual simulation does not
have a feasible interpretation, since we are usually not able to let a system revert
its actions. For graphs, in general, and graph database objects, this makes sense,
since an object may be part of a relation, either as subject or object, which is
equally important w. r. t. the represented relation.
      </p>
      <p>De nition 3. Let Gi = (Vi; ; Ei) (i = 1; 2) be two graphs. A dual simulation
between G1 and G2 is a relation S V1 V2 such that (a) for each node v1 2 V1,
there is v2 2 V2 such that (v1; v2) 2 S and (b) for each (v1; v2) 2 S,
1. v1 a!1 v10 implies that there is a v20 2 V2 with v2 a!2 v20 and (v10; v20) 2 S,
2. v10 a!1 v1 implies that there is a v20 2 V2 with v20 a!2 v2 and (v10; v20) 2 S.
Let DB be a graph database and Q be a graph pattern. A subgraph G of DB is
a dual simulating match of Q in DB i Q D G. The set of all dual simulating
matches of Q in DB is denoted by JQKDBD .</p>
      <p>It is easy to show that the union of two dual simulations again yields a dual
simulation. Since an assignment to a BGP is a homomorphism, we obtain only
matches respecting at least the edge structure of a pattern. Therefore, each
assignment corresponds also to a dual simulating match.</p>
      <p>Proposition 1. Let DB be a graph database and P a graph pattern. Then for
all 2 JP^KDB, it holds that (P^) 2 JP KDBD .</p>
      <p>For every 2 JP^KDB, S = f(v; ( (v))) j v 2 VP g is the desired dual
simulation. The converse does not hold, in general. This is because given a dual
simulating match of a graph pattern P , every graph that contains this match as
a subgraph is also a match. In theory, if the size of the database as well as the
maximum in- and out-degrees of the database nodes are given, one could try to
iteratively build BGPs extending the given graph pattern by structures allowed
for dual simulation. Such a methodology is rather costly, since we may assume
the database to be very large. In contrast, a query is often smaller, easily
rendering the answers produced by the enlarged query useless. In fact, if there is at
least one dual-simulating match in the graph database, then the graph database
itself is also a match. Strong simulation overcomes these issues by limiting the
size of matches by the diameter of the pattern. Matches to the graph pattern
are locally bounded. Furthermore, irrelevant edges in the match are ltered out,
letting a characterization of the respective SPARQL queries come in reach.</p>
      <p>In order to exclude irrelevant edges, and thus, also nodes from a matching,
the notion of match graph of a dual simulation S is introduced. In a match graph
of S, each node and each edge play a role in the simulation. Formally, a graph G
is a match graph w. r. t. dual simulation S i (a) for each node v of G, there is a
pair (x; v) 2 S for some node x of the pattern, and (b) for each edge v1 a! v2,
there is an edge u1 a! u2 in the pattern such that (ui; vi) 2 S (i = 1; 2). While
strong simulation considers match graphs of special dual simulations, as we will
explain in the next subsection, also dual simulation may bene t from this notion.
By jGj we denote the size of G, de ned as the number of nodes in G. Considering
all graphs G 2 JP KDBD for some graph pattern P , if G contains at most as many
nodes as P , i. e., jGj jP j, then an assignment constructing the match G exists.
Lemma 1. Let DB be a graph database and P a graph pattern. For all matches
G 2 JP KDBD with dual simulation S such that jGj jP j and G is a match graph
w. r. t. S, there is a 2 JP^KDB such that (P^) = G.</p>
      <p>Proof. Let G be a dual simulating match of P under dual simulation S, as
required. Then S is a homomorphism between P and G. Each node of the pattern
has exactly one simulating node in G, since G is a match graph w. r. t. S (cond.
(a)) and jGj jP j. As G dual simulates P , an edge in P is re ected by an edge in
G, homomorphically. From match graph cond. (b), it follows that each edge in G
is re ected by some edge in the pattern. By taking = S, we get (P^) = G.
tu
5.2</p>
      <p>
        Strong Simulating Matches
The last Lemma has given an exact characterization of valid assignments of
SPARQL BGPs in terms of matching by dual simulation. In this section, we
look at further restrictions on dual simulations, culminating to the notion of
strong simulation. Strong simulation is an extension of dual simulation, i. e., a
match still needs to dual simulate the pattern (e. g., reconsider Fig. 3(a) as not
strong simulating), but this time, a simulation S certifying for dual simulation
must be maximal, i. e., any other dual simulation is already contained in S.
Uniqueness of the maximal dual simulation is easy to show and may be found,
e. g., in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. Furthermore, a prospective graph needs to be a match graph w. r. t.
maximal dual simulation S.
      </p>
      <p>
        Strong simulation aims at keeping possible matches locally constrained such
that the size of a match is bounded and also the overall number of matches is
non-exponential. In order to meet this locality requirement, matches are bounded
in the diameter d of the pattern in such a way that for every match, there is
a node having distance at most d to any other node, e. g., Fig. 3(b) is not
strong simulating to the graph pattern in Fig. 1(a), because the match graph
is disconnected. Therefore, the locality requirement is violated. Formally, we
require a match to be a subgraph of a so-called ball of the database DB. Let v
be a node of DB and r 2 N a radius. Then the subgraph of DB containing node
v and all nodes and edges reached from v in at most r steps (backwards and
forwards along the edges) is called a ball of DB, denoted DdB[v; r]. For strong
simulation, the radius is chosen to be the diameter of the graph pattern.
De nition 4. Let DB be a graph database and P a graph pattern (dia(P ) = d).
Subgraph G of DB is a strong simulating match of P in DB i there is a node v
such that G is a subgraph of DdB[v; d] containing v with the following properties:
(1) P D G by maximal dual simulation S and (2) G is the match graph of S.
By JP KDBS we denote the set of all strong simulating matches of P .
Both, Fig. 1(b) and Fig. 1(c) are strong simulating matches of the pattern in
Fig. 1(a). Ma et al. [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] call a strong simulating match perfect subgraph. In the
spirit of Proposition 1, one can show that each assignment also corresponds to
a strong simulating match. Again, not all matches can be recovered by a simple
transformation of a graph pattern into a BGP. However, since the size of the
matches is bounded by the diameter of the given graph pattern, an iterative
method, like the one explained at the end of Sect. 5.1, may be feasible.
      </p>
      <p>The rest of this section is devoted to proving the existence of a SPARQL
query for graph pattern P , i. e., a P -query for strong simulation. Therefore, we
rst look at the SPARQL answers, already giving us strong simulating matches,
and join them to bigger answers, similar to the SPARQL and -operation (cf.
Sect. 3). We then prove that for every strong simulating match there is a set of
SPARQL assignments that amounts to the graph by joining the components. The
resemblance of our join operator allows us to conclude that there is a SPARQL
query re ecting the strong simulating matches of a graph pattern.</p>
      <p>The join of two subgraphs of DB is the union of both graphs if they are
compatible. Two graphs are compatible i they share at least one node. Remember
that we assume only connected graphs as graph patterns, justifying this stronger
condition compared to the and -operator of SPARQL.</p>
      <p>De nition 5. Let DB be a graph database. Two subgraphs G1; G2 v DB are
compatible i V1 \ V2 6= ;. The join of compatible graphs G1 and G2 is de ned
as the graph G1 IJ G2 = (V1 [ V2; ; E1 [ E2).</p>
      <p>Joining arbitrary strong simulating matches still yields dual simulating matches,
but the locality requirement may be violated. Therefore, a second form of
compatibility is necessary which restricts the possible combinations of strong
simulating matches to be joined. For a graph G and radius r 2 N, C(G; r) denotes the
set of center nodes of G w. r. t. r, i. e., all other nodes may be reached in at most
r steps (ignoring the directions of the edges). Restricting IJ to only join center
nodes w. r. t. the diameter of the pattern maintains the locality requirement of
strong simulation.</p>
      <p>De nition 6. Let DB be a graph database and r 2 N a radius. Compatible
subgraphs G1; G2 v DB are r-compatible i V1 \ V2 C(G1; r) \ C(G2; r).
While IJ alone is commutative and associative, we loose associativity requiring
r-compatibility. Therefore, we assume left-associativity of IJ throughout the
rest of the paper. The join of two strong simulating matches of a graph pattern
P is again a strong simulating match of P if the matches are d-compatible with
d = dia(P ). This is because the union of two (maximal) dual simulations yields
a (maximal) dual simulation and, as long as only center nodes are joined, the
distance requirement of strong simulation remain una ected. This insight paves
the way for the main theorem of this section. Every strong simulating match
of pattern P may be reconstructed out of assignments of query P^. Since empty
matches are trivially constructible, from zero BGP assignments, we rule out this
case in the next theorem.</p>
      <p>Theorem 2. Let DB be a graph database, P a graph pattern with diameter d,
and G 2 JP KDBS be non-empty. There are assignments 1; 2; : : : ; k 2 JP^KDB
such that for each 0 &lt; j &lt; k, 1(P^) IJ : : : IJ j (P^) and j+1(P^) are
dcompatible and 1(P^) IJ 2(P^) IJ : : : IJ k(P^) = G.</p>
      <p>Corollary 1. Let DB be a graph database and P a graph pattern. Then there
exists a P -query for strong simulation Q S (P ).
6</p>
    </sec>
    <sec id="sec-6">
      <title>Conclusion</title>
      <p>We provided novel insights into the relation between the widespread graph query
languages, exempli ed by SPARQL, and graph pattern matching. Thereby, we
obtained a fresh look at the expressive power of graph query languages w. r. t.
well-understood graph pattern matching relations. To the best of our knowledge,
this is the rst attempt that characterizes graph pattern matching relations by
state-of-the-art graph query languages. Our ndings are general in that every
query language complete w. r. t. the SPARQL semantics we used (cf. Sect. 3),
may reproduce our theorems. By the homomorphic nature of the SPARQL
semantics, it was possible to formulate simple queries consisting only of a BGP
and a lter condition that constructs all isomorphic matches of a given graph
pattern (cf. Theorem 1). Removing the somewhat arti cial lter condition from
P -queries for graph isomorphism, thus only considering BGPs, yielded queries
returning dual simulating matches. From a computational point of view, the
construction of a query capturing all dual simulating matches is rather costly.
However, limiting matches to relevant (w. r. t. the pattern) nodes and edges
allows to fully characterize dual simulation in this spirit (cf. Lemma 1). Ultimately,
we showed the existence of SPARQL queries for matching by strong simulation,
an extension of dual simulation that locally restricts the size of the matches (cf.
Theorem 2 and Corollary 1). As our rst point for future work, we would like to
give a constructive proof of Theorem 2 in order to make our ndings applicable.</p>
      <p>
        From a practical perspective, our results may be bene cial to query
processing performance in very large graph databases. It is known that the evaluation
of SPARQL queries itself is coNP-complete [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. In contrast, graph pattern
matching based on strong simulation only needs cubic time [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. Query processing
heuristics built on existing strong simulation algorithms could therefore lead to
improvements with regard to general graph database query processing. Thereby,
strong simulating matches may serve as over-approximations of BGPs, possibly
reducing the number of relevant candidate assignments. Whether or not
preprocessing of graph database queries by strong simulation leads to a signi cant
reduction of computational time is left to an empirical evaluation. Further
investigations on the interplay of BGPs and other graph query operations need to
be performed.
We show the two directions, separately.
if: Let 2 JQ=(P )KDB be an assignment. We need to show that (P^) is an
isomorphic match of P , i. e., P = (P^). Therefore, we prove that is an
isomorphism. By our observation that is an isomorphism and isomorphisms
are preserved by function composition, it is su cient to show that is an
isomorphism. is injective due to the lter condition 'P . is surjective by
the de nition of a valid assignment. Thus, is an isomorphism.
only if: Let G be an isomorphic match of P . Thus, there is an isomorphism
between P and G. Isomorphisms are closed under reversal, i. e., 1 is also
an isomorphism. Furthermore, 1 is an isomorphism for the same reason.
We construct an assignment by composing these two isomorphisms as =
1 1. is an isomorphism, thus a bijective homomorphism and a valid
assignment for P^, resulting in (P^) = G.
We proceed by induction on the size of the graph G, estimated by the number k
of assignments needed to construct G. In the base case, k = 1, we look at graphs
G 2 JP KDBS with jGj jP j. The statement follows directly from Lemma 1.
      </p>
      <p>Assume for some i, the claim holds in case k = i and any smaller number.
We need to show that the claim also holds in case k = i + 1. The induction
hypothesis implies that for every match G with jGj i (jP j 1) + 1, there are
at most i assignments constructing the match. This follows from the base case
constructing graphs of size at most jP j, while any further addition contributes
at most jP j 1 nodes to the graph, since by assumption at least one center node
is involved in the join.</p>
      <p>For case k = i + 1, we establish the following bound of the size of G,
i + jP j = i (jP j
induction hypothes}is
| {z
1) + 1 +(jP j
1).</p>
      <p>Towards a contradiction, suppose G is not constructible from the assignments
of the BGP P^. Then there is a largest constructible subgraph G0 v G, which
needs at most i assignments, and they exist by the induction hypothesis. The
subgraph of G that has no shared nodes with G0 is bounded by jP j 1 due to the
above equation. There is at least one edge v0 a! v (or v a! v0, resp.) with v0
is in G0 and v is in G but not in G0. Since G is a match of P , there is a smallest
subgraph G00 of the database with G00 v G, containing v0 a! v (v a! v0, resp.)
and dual simulating P . If G00 is not a sugraph of G, then there is an edge outside
of G necessary to dual simulate pattern P ; establishing a contradiction to the
assumption that G is a strong simulating match of P . Since the size of G00 is also
bounded due to the equation above, G00 adds no more than jP j 1 nodes to G0.
By Lemma 1, there is an assignment of P^ that amounts to G00. Since this step
may be repeated until no more edges remain, constructibility of G is implied.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Brynielsson</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Hogberg, J.,
          <string-name>
            <surname>Kaati</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Martenson</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Svenson</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Detecting Social Positions Using Simulation</article-title>
          .
          <source>In: ASONAM 2010</source>
          . pp.
          <volume>48</volume>
          {
          <issue>55</issue>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Fan</surname>
          </string-name>
          , W.:
          <article-title>Graph Pattern Matching Revised for Social Network Analysis</article-title>
          .
          <source>In: ICDT 2012</source>
          . pp.
          <volume>8</volume>
          {
          <fpage>21</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          , New York, NY, USA (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Fan</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Li</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Ma,
          <string-name>
            <given-names>S.</given-names>
            ,
            <surname>Tang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            ,
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            ,
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <surname>Y.</surname>
          </string-name>
          :
          <article-title>Graph pattern matching: From intractable to polynomial time</article-title>
          .
          <source>PVLDB Endow</source>
          .
          <volume>3</volume>
          (
          <issue>1-2</issue>
          ),
          <volume>264</volume>
          {275 (Sep
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Fan</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Li</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , Ma,
          <string-name>
            <given-names>S.</given-names>
            ,
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            ,
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <surname>Y.</surname>
          </string-name>
          :
          <article-title>Graph Homomorphism Revisited for Graph Matching</article-title>
          .
          <source>In: Proc. of VLDB '10</source>
          . vol.
          <volume>3</volume>
          , pp.
          <volume>1161</volume>
          {
          <issue>1172</issue>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Gallagher</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Matching Structure and Semantics: A Survey on Graph-Based Pattern Matching</article-title>
          .
          <source>In: Papers from the AAAI FS '06</source>
          . pp.
          <volume>45</volume>
          {
          <issue>53</issue>
          (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. van Glabbeek,
          <string-name>
            <surname>R.J.:</surname>
          </string-name>
          <article-title>The linear time - branching time spectrum</article-title>
          . In: Baeten,
          <string-name>
            <given-names>J.C.M.</given-names>
            ,
            <surname>Klop</surname>
          </string-name>
          ,
          <string-name>
            <surname>J.W. (eds.) CONCUR</surname>
          </string-name>
          <year>1990</year>
          . pp.
          <volume>278</volume>
          {
          <fpage>297</fpage>
          . Springer, Berlin, Heidelberg (
          <year>1990</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>He</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Singh</surname>
            ,
            <given-names>A.K.</given-names>
          </string-name>
          :
          <article-title>Graphs-at-a-time: query language and access methods for graph databases</article-title>
          .
          <source>In: Proc. of SIGMOD'08</source>
          . p.
          <fpage>405</fpage>
          . ACM Press, New York, New York, USA (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Lee</surname>
            , J., Han,
            <given-names>W.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kasperovics</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lee</surname>
            ,
            <given-names>J.H.:</given-names>
          </string-name>
          <article-title>An In-depth Comparison of Subgraph Isomorphism Algorithms in Graph Databases</article-title>
          .
          <source>PVLDB Endow</source>
          .
          <volume>6</volume>
          (
          <issue>2</issue>
          ),
          <volume>133</volume>
          {144 (Dec
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Ma</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cao</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Fan</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Huai</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wo</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>Strong Simulation: Capturing Topology in Graph Pattern Matching</article-title>
          .
          <source>ACM Trans. Database Syst</source>
          .
          <volume>39</volume>
          (
          <issue>1</issue>
          ), 4:
          <issue>1</issue>
          {4:
          <fpage>46</fpage>
          (Jan
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Milner</surname>
            ,
            <given-names>R.:</given-names>
          </string-name>
          <article-title>An algebraic de nition of simulation between programs</article-title>
          .
          <source>In: Proc. of IJCAI'71</source>
          . pp.
          <volume>481</volume>
          {
          <fpage>489</fpage>
          . Morgan Kaufmann Publishers Inc. (
          <year>1971</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Mottin</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lissandrini</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Velegrakis</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Palpanas</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>Exemplar Queries: A New Way of Searching</article-title>
          .
          <source>The VLDB Journal</source>
          <volume>25</volume>
          (
          <issue>6</issue>
          ),
          <volume>741</volume>
          {765 (Dec
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Perez</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Arenas</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gutierrez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Semantics and complexity of SPARQL</article-title>
          .
          <source>ACM Transactions on Database Systems</source>
          <volume>34</volume>
          (
          <issue>3</issue>
          ),
          <volume>1</volume>
          {
          <fpage>45</fpage>
          (Aug
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Prud'hommeaux</surname>
          </string-name>
          , E.,
          <string-name>
            <surname>Seaborne</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>SPARQL Query Language for RDF (</article-title>
          <year>2008</year>
          ), http://www.w3.org/TR/rdf-sparql-query/
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Wood</surname>
          </string-name>
          , P.T.:
          <article-title>Query languages for graph databases</article-title>
          .
          <source>SIGMOD Rec</source>
          .
          <volume>41</volume>
          (
          <issue>1</issue>
          ),
          <volume>50</volume>
          {60 (Apr
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          <source>Proof of Theorem 1 1) + 1 = i jP j</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>