Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
}
]
},
"graphName": "AntiFraud",
"graphName": "Supply_Chain_Management",
"hideWidgetName": false,
"id": "jiFArchKghkbBhGC4d548q",
"patternLimit": 5,
Expand Down Expand Up @@ -853,7 +853,7 @@
}
]
},
"graphName": "AntiFraud",
"graphName": "Supply_Chain_Management",
"hideWidgetName": false,
"id": "7GwzFLnQ5dDDVtUtVx7mPv",
"patternLimit": 5,
Expand Down Expand Up @@ -1041,7 +1041,7 @@
"id": "input_35dZipma5w14zcPa9srhP7",
"name": "vertType",
"settings": {
"graphName": "AntiFraud",
"graphName": "Supply_Chain_Management",
"open": false,
"options": [
{
Expand Down Expand Up @@ -1111,7 +1111,7 @@
}
]
},
"graphName": "AntiFraud",
"graphName": "Supply_Chain_Management",
"hideWidgetName": false,
"id": "wGYxHtNz9dmfUBHvh8vi8a",
"patternLimit": 5,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
CREATE OR REPLACE DISTRIBUTED QUERY explore_BOM_insights(STRING vertType,STRING id, INT depth, BOOL upstream) FOR GRAPH Supply_Chain_Management {
/*
Query Name: explore_BOM_insights
Multi-level BOM exploration (downstream) or where-used analysis (upstream)
starting from a vertex identified by (vertType, id).

Key Use Cases:
. Explode a material/BOM into its components and related suppliers (downstream)
. Reverse trace: find BOMs/material relationships and supply paths (upstream)
. Useful for impact analysis, sourcing visibility, and BOM troubleshooting.

Parameters:
vertType (STRING):
Vertex type name of the starting vertex (e.g., Material, BOM, Supplier)
id (STRING):
Primary/external ID of the starting vertex (converted via to_vertex(id, vertType))
depth (INT):
Maximum traversal depth
upstream (BOOL):
TRUE -> Where-used / reverse trace
FALSE -> BOM explosion / forward trace

Output:
Prints the traversed edge set (@@edges) and vertex set (@@nodes).
*/
SetAccum<EDGE> @@edges;
SetAccum<VERTEX> @@nodes;
OrAccum @visited;
OrAccum @isSrc;
vertex vertss;
vertss = to_vertex(id,vertType);
// get src
verts = {vertss};
verts = select s from verts:s ACCUM s.@isSrc += TRUE,@@nodes += s;

// while loop
WHILE verts.size() > 0 LIMIT depth DO
// traverse up or down
IF upstream == TRUE THEN
verts =
SELECT t FROM verts:s -((Supplies|reverse_Has_Component_Material|reverse_Produced_By):e)- (Material|BOM):t
WHERE t.@visited == FALSE
ACCUM @@edges += e,@@nodes += t
POST-ACCUM
s.@visited = TRUE;
ELSE
verts =
SELECT t FROM verts:s -((reverse_Supplies|Has_Component_Material|Produced_By):e)- (Material|BOM|Supplier):t
WHERE t.@visited == FALSE
ACCUM @@edges += e,@@nodes += t
POST-ACCUM
s.@visited = TRUE;
END;
END;

// print edges
PRINT @@edges;
nodes = {@@nodes};
PRINT nodes;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
CREATE OR REPLACE DISTRIBUTED QUERY explore_BOM_line_Insights(STRING vertType,STRING id, INT depth, BOOL upstream, BOOL use_date_range, DATETIME start_date, DATETIME end_date) FOR GRAPH Supply_Chain_Management {
/*
Description:
End-to-end transactional lineage traversal (order-to-cash & procure-to-pay)
across actual production instances (SFC), sales orders, purchase orders,
shipments, and customers/suppliers.

This is the "digital thread" query — it connects the physical flow
(what was actually built and shipped) with the commercial flow
(who ordered it and who supplied the components).

Parameters:
vertType (STRING):
Vertex type name of the starting vertex — typically SFC_Material (actual batch),
Sales_Order, Purchase_Order, Customer, or Supplier
id (STRING):
Primary/external ID of the starting vertex (paired with vertType and converted
to a vertex via to_vertex(id, vertType))
depth (INT):
Maximum traversal depth
upstream (BOOL):
FALSE → Follow the flow downstream
TRUE → Follow the flow upstream
use_date_range (BOOL):
If TRUE, only traverse through dated vertices (Sales_Order, Purchase_Order,
SFC_Assembly) that fall within the specified window
start_date / end_date (DATETIME):
Optional time fence for filtering transactional vertices

*/
Comment thread
abrahamchandy95 marked this conversation as resolved.
SetAccum<VERTEX> @@nodes;
OrAccum @isSrc;
vertex vertss;
vertss = to_vertex(id,vertType);
// get src
verts = {vertss};
verts = select s from verts:s ACCUM s.@isSrc += TRUE,@@nodes += s;

SetAccum<EDGE> @@edges;
OrAccum @visited;


// while loop
WHILE verts.size() > 0 LIMIT depth DO
// traverse up or down
IF upstream == TRUE THEN
verts =
SELECT t FROM verts:s -((Has_Purchase_Order|Has_Line_Number|reverse_Used_For|
reverse_Has_Component_SFC|reverse_To_Be_Produced_By|reverse_For_Material|
reverse_Has_Sales_Order_Item|reverse_Has_Sales_Order):e)-
(Purchase_Order|Line_Number|SFC_Material|SFC_Assembly|Sales_Order_Item|Sales_Order|Customer):t
WHERE t.@visited == FALSE
// relevant vertices in date range (SFC_Assembly,Sales_Order,Purchase_Order)
ACCUM @@edges += e,@@nodes += t
POST-ACCUM
s.@visited = TRUE;
ELSE
verts =
SELECT t FROM verts:s -((reverse_Has_Purchase_Order|reverse_Has_Line_Number|Used_For|
Has_Component_SFC|To_Be_Produced_By|For_Material|
Has_Sales_Order_Item|Has_Sales_Order):e)-
(Supplier|Purchase_Order|Line_Number|SFC_Material|SFC_Assembly|Sales_Order_Item|Sales_Order):t
WHERE t.@visited == FALSE
// relevant vertices in date range (SFC_Assembly,Sales_Order,Purchase_Order)
ACCUM @@edges += e,@@nodes += t
POST-ACCUM
s.@visited = TRUE;
END;//Based_On,reverse_Based_On,Happens_At,reverse_Happens_At,Produced_By,reverse_Produced_By,Has_Component_Material,reverse_Has_Component_Material,SFC_To_Material,reverse_SFC_To_Material,Supplies,reverse_Supplies,Has,reverse_Has
END;

// print edges
PRINT @@edges;
nodes = {@@nodes};
PRINT nodes;
PRINT "explore_BOMLine works!";
}
1 change: 1 addition & 0 deletions financial_crime/entity_resolution_kyc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ and Know Your Customer (KYC) compliance. It enables the creation of a Single Cus
View (SCV) by linking scattered records through weighted attribute matching,
detecting fraud rings in real-time, and generating powerful graph features for
downstream machine learning models.

---

## Contents
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultGraph": "AntiFraud",
"defaultGraph": "Entity_Resolution_KYC",
"iconURL": "/insights/static/media/atom.14f5dd297b1a450cae3413a44f69a75b.svg",
"id": "arDCiwHPNbgkqU51x1tBNY",
"pageConfigSeparated": true,
Expand Down Expand Up @@ -334,7 +334,7 @@
}
]
},
"graphName": "AntiFraud",
"graphName": "Entity_Resolution_KYC",
"hideWidgetName": false,
"id": "pWVjbPx54GYQyYYTHe8Qpj",
"patternLimit": 5,
Expand Down
Loading