Skip to content

Instantly share code, notes, and snippets.

MATCH (a), (b), p = allShortestPaths((a)-[*..{{"Maximum path length":number:{"default": 4, "min": 1, "max": 10}}}]-(b))
WHERE ALL (r IN relationships(p)
WHERE type(r)= 'IS_SHAREHOLDER' AND r.shares > 0.20) AND id(a) = {{"Source":node:"Person"}} AND id(b) = {{"Target":node:"Company"}}
RETURN p LIMIT {{"Maxiumum number of paths":number:{"default":5, "min": 1, "max": 50}}}
MATCH (n)
WHERE id(n) = {{"Suspicious Entity":node:["Person"]}}
SET n.suspicious = true
SET n.note = {{"Comment":string:{"placeholder":"Add a note..."}}}
RETURN n;
MATCH (b:BANK_ACCOUNT)-[e:HAS_TRANSFERED]->(a)
WHERE id(a) = {{"Bank":node:"BANK_ACCOUNT"}} and e.amount > {{"Amount":number:{"min":0}}} and e.date >= {{"Start date":date:"iso"}} and e.date < {{"End date":date:"iso"}}
return a, e, b
MATCH p=(a:Company)-[rs:SELLS_TO*]->(c:Company)
WHERE a.country <> c.country
WITH p, a, c, rs, nodes(p) AS ns
WITH p, a, c, rs, filter(n IN ns WHERE n.epoch - 1383123473 < (90*60*60*24)) AS bs
WITH p, a, c, rs, head(bs) AS b
WHERE NOT b IS NULL
WITH p, a, b, c, head(rs) AS r1, last(rs) AS rn
WITH p, a, b, c, r1, rn, rn.epoch - r1.epoch AS d
WHERE d < (15*60*60*24)
RETURN a, b, c, d, r1, rn
// 1) match all disputed transactions
match (p:person)-[b:HAS_BOUGHT_AT {status: "Disputed"}]->(m:merchant)
with
collect(p) as disputer, // list of persons with disputed transactions
collect(b) as disputed, // list disputed transactions
collect(m) as merchants // list merchants with disputed transactions
// 2) match all undisputed transactions
match (p:person)-[b:HAS_BOUGHT_AT {status: "Undisputed"}]->(m:merchant)
where p in disputer // keep only transactions where the buyer is a disputer
with // group undisputed transactions by merchant
@elisedeux
elisedeux / Guest Mode URL Parameters
Created November 9, 2018 13:19
Guest Mode URL Parameters
# Load a node by node ID
/guest?populate=nodeId&item_id=123&key=a1b1c1
# Load an edge and its source and target nodes by edge ID
/guest?populate=edgeId&item_id=123&key=a1b1c1
# Load a node and its neighbors by node ID
/guest?populate=expandNodeId&item_id=123&key=a1b1c1
# Load nodes (by search query)
@elisedeux
elisedeux / gist:23954c8932ccfe94be7126a240688a82
Created August 2, 2018 12:19
Global_terrorism_database_Cypher_import
// Create node events
load csv with headers from "file:///bdd.csv" as row
merge(e:Event {id: row.eventid})
set e.nature=row.attacktype1_txt
set e.year=row.iyear
set e.month=row.imonth
set e.date=row.iday
Set e.latitude=row.latitude
Set e.longitude=row.longitude
@elisedeux
elisedeux / Query template used to expand a person's bank account node and its ten highest associated transactions.
Last active May 8, 2018 07:57
Query template used to expand a person's bank account node and its ten highest associated transactions.
MATCH (c:PERSON)-[e1:HAS_BANK_ACCOUNT]->(cc:BANK_ACCOUNT)-[e2:HAS_RECEIVED]->(t:TRANSACTION)
WHERE ID(c) = {{"PERSON":node:"PERSON"}}
RETURN c, e1, cc, e2, t
ORDER BY t.amount DESC
LIMIT 10
MATCH (c1:Customer)-[r*1..4]-(c2:Customer)
WHERE ID(c1) = {{"customer":node:"Customer"}}
return c1, r, c2
// Create the class with a low opacity value
ogma.createClass('faded', {
nodeAttributes: { opacity: 0.2 },
edgeAttributes: { opacity: 0.2 }
});
// Select the nodes and edges that must be faded
const nodesToFade = ogma.getNodes().filter(node => node.getData('type') === 'INVESTOR');
const edgesToFade = nodesToFade.getAdjacentEdges();