3 \begin{enumerate}[label=(\alph*),leftmargin=2\parindent]
4 \item\textbf{Two basic queries to start with:}
6 \item\textbf{List all the distinct countries for which addresses are
7 registered in the database.}
8 \begin{lstlisting}[style=command]
9 MATCH (n:Address) RETURN DISTINCT n.countries AS countries
11 This returns 222 different countries. We chose ''Austria''.
14 \item\textbf{Choose one of these countries and list 5 entities which
15 are based in that country.}
16 \begin{lstlisting}[style=command]
17 MATCH (n:Address {countries: 'Austria'})<-[r:REGISTERED_ADDRESS]-(e:Entity)
18 RETURN DISTINCT e AS entity LIMIT 5
20 \input{results/result_3a.tex}
25 \begin{enumerate}[label=\roman*,leftmargin=1\parindent]
26 \item\textbf{First, find the 10 \texttt{top intermediaries} , i.e.
27 those 10 intermediaries that have the most outgoing
28 \texttt{INTERMEDIARY\_OF} edges. Output the name of the
29 intermediary as well as the number of relevant edges.}
30 \begin{lstlisting}[style=command]
31 MATCH (n:Intermediary)-[r:INTERMEDIARY_OF]->()
32 RETURN n.name AS name, COUNT(r) AS count ORDER BY count DESC LIMIT 10
34 \input{results/result_3b1.tex}
37 \item\textbf{Extend the query of \texttt{i} to also count outgoing
38 \texttt{OFFICER\_OF} edges to determine the top intermediaries.
39 Output the name of the intermediary as well as the number of
41 \begin{lstlisting}[style=command]
42 MATCH (n:Intermediary)-[r:INTERMEDIARY_OF|OFFICER_OF]->()
43 RETURN n.name AS name, COUNT(r) AS count ORDER BY count DESC LIMIT 10
45 \input{results/result_3b2.tex}
48 \item\textbf{For the top intermediary from query \texttt{ii},
49 output all the outgoing edges, except for those that have type
50 either \texttt{OFFICER\_OF} or \texttt{INTERMEDIARY\_OF}. Also
51 output the respective nodes at the other side of the edges.}
52 \begin{lstlisting}[style=command]
53 MATCH (n:Intermediary {node_id: "54662"})-[r]->(t)
54 WHERE NOT (n)-[r:INTERMEDIARY_OF|OFFICER_OF]->(t)
55 RETURN type(r) AS relation, t.node_id AS node
57 \input{results/result_3b3.tex}
61 \item\textbf{Find a shortest \textit{undirected} path between an Address in
62 Luxembourg and an Address in Cyprus where the path has a length of at
63 least 16 and at most 30.}
65 \begin{lstlisting}[style=command]
66 MATCH p=shortestPath((lux:Address{countries:"Luxembourg"})-[*1..30]-(cyp:Address{countries:"Cyprus"}))
67 WITH *, length(p) AS len WHERE len >= 16 AND len < 17
68 //RETURN lux, cyp, len LIMIT 10
72 Adjusting the values only produced different graphs, but there were
73 always more than 10 paths available.
74 One of these graphs we included, to show at least one result.
76 \input{results/result_3c.tex}
80 \includegraphics[width=12cm]{results/result_3c.png}
82 \item\textbf{Find one (use \texttt{LIMIT 1}) subgraph of the form specied
83 in Figure 4 in the database.
84 Furthermore, the two entities should be in different countries and at
85 least one of the entities should have different values in its
86 \texttt{jurisdiction} and \texttt{country\_codes} attributes.}
87 \begin{lstlisting}[style=command]
88 MATCH (i:Intermediary)-->(e1:Entity)<--(o:Officer)-->(e2:Entity)<--(i:Intermediary)
90 AND e1.countries <> e2.countries
91 AND (e1.jurisdiction <> e1.country_codes
92 OR e2.jurisdiction <> e2.country_codes)
98 \includegraphics[width=6cm]{results/result_3d.png}
100 \item\textbf{For the final task we want to make the \texttt{countries}
101 attribute a real part of the graph.
102 The best way to do this is in Neo4j is using the \texttt{MERGE} keyword
103 inside of a \texttt{MATCH}. The task is restricted to the nodes with
104 label \texttt{Other} to avoid processing an unnecessarily large amount
106 \begin{lstlisting}[style=command]
107 MATCH (other:Other) WHERE exists(other.countries)
108 MERGE (country:Country { name: other.countries })
109 MERGE (other)-[r:IN_COUNTRY]->(country)
111 \input{results/result_3e.tex}
112 \begin{lstlisting}[style=command]
113 MATCH (c:Country{ name:"Mauritius" }) RETURN c
117 \includegraphics[width=5cm]{results/result_3e.png}