共用方式為


make-graph 運算符

運算子 make-graph 會從邊緣和節點的表格式輸入建置圖形結構。

語法

Edges | make-graph SourceNodeId TargetNodeId --> [ Nodes1 on NodeId1 [, with Nodes2 on NodeId2 ]]

參數

姓名 類型​​ 必要 描述
邊緣 string ✔️ 包含圖形邊緣的表格式來源,每個數據列都代表圖形中的邊緣。
SourceNodeId string ✔️ Edge 中具有邊緣來源節點標識碼的數據行。
TargetNodeId string ✔️ Edge 中具有邊緣目標節點標識碼的數據行。
節點 string 包含圖形中節點屬性的表格式表達式。
NodesId string 節點中具有節點標識碼的數據行。

傳回

make-graph運算符會傳回圖表表達式,且後面必須接著圖形運算元。 來源 Edges 運算式中的每個數據列都會變成具有數據列數據行值之圖形的邊緣。 節點表格式表示式中的每個數據列都會成為圖形中的節點,其中包含數據列數據行值的屬性。 出現在 Edges 數據表但節點數據表中沒有對應數據列的節點會建立為具有對應節點識別碼和空白屬性的節點。

注意

每個節點都有唯一標識碼。 如果 Nodes1Nodes2 資料表中出現相同的節點識別碼,則會藉由合併其屬性來建立單一節點。 如果相同節點有衝突的屬性值,則會任意選擇其中一個值。

範例

下列範例會從邊緣和節點數據表建置圖形。 節點代表人員和系統,而邊緣是節點之間的不同關聯性。 運算子 make-graph 會建置圖形。 接著,使用圖表模式呼叫 graph-match ,以搜尋「Trent」系統節點的攻擊路徑。

let nodes = datatable(name:string, type:string, age:int) 
[ 
  "Alice", "Person", 23,  
  "Bob", "Person", 31,  
  "Eve", "Person", 17,  
  "Mallory", "Person", 29,  
  "Trent", "System", 99 
]; 
let edges = datatable(source:string, destination:string, edge_type:string) 
[ 
  "Alice", "Bob", "communicatesWith",  
  "Alice", "Trent", "trusts",  
  "Bob", "Trent", "hasPermission",  
  "Eve", "Alice", "attacks",  
  "Mallory", "Alice", "attacks",  
  "Mallory", "Bob", "attacks"  
]; 
edges 
| make-graph source --> destination with nodes on name 
| graph-match (mallory)-[attacks]->(compromised)-[hasPermission]->(trent) 
  where mallory.name == "Mallory" and trent.name == "Trent" and attacks.edge_type == "attacks" and hasPermission.edge_type == "hasPermission" 
  project Attacker = mallory.name, Compromised = compromised.name, System = trent.name

輸出

攻擊者 遭洩漏 系統
馬婁裡 Bob 特 倫 特