共用方式為


graph-to-table 運算符

運算子會將 graph-to-table 節點或邊緣從圖形匯出至數據表。

注意

這個運算子會與 make-graph運算子搭配使用。

語法

節點

G graph-to-table nodes | [ with_node_id=ColumnName ]

邊緣

G | graph-to-table edges [ ColumnName ] [ with_target_id=with_source_id=ColumnName ] [ as TableName ]

節點和邊緣

G graph-to-table nodes | as NodesTableName [ with_node_id=ColumnName ], edges as EdgesTableName [ with_source_id=ColumnName ] [ with_target_id=ColumnName ]

參數

姓名 類型​​ 必要 描述
G string ✔️ 輸入圖表來源。
NodesTableName string 匯出節點數據表的名稱。
EdgesTableName string 匯出邊緣數據表的名稱。
ColumnName string 匯出具有指定數據行名稱的節點哈希標識碼、來源節點哈希標識碼或目標節點哈希標識碼。

傳回

節點

運算符 graph-to-table 會傳回表格式結果,其中每個數據列都會對應至來源圖表中的節點。 傳回的數據行是節點的屬性。 提供 時 with_node_id ,節點哈希資料行的類型 long 為 。

邊緣

運算符 graph-to-table 會傳回表格式結果,其中每個數據列對應至來源圖形中的邊緣。 傳回的數據行是節點的屬性。 提供或 with_target_idwith_source_id,節點哈希資料行的類型long為 。

節點和邊緣

運算符 graph-to-table 會傳回兩個表格式結果,符合先前的描述。

範例

下列範例會使用 make-graph 運算符,從邊緣和節點數據表建置圖形。 節點代表人員和系統,而邊緣是節點之間的不同關聯性。 然後,每個範例都會顯示 不同的用法 graph-to-table

取得邊緣

在此範例中,運算符會將 graph-to-table 邊緣從圖形匯出至數據表。 with_source_idwith_target_id 參數會匯出每個邊緣來源和目標節點的節點哈希。

let nodes = datatable(name:string, type:string, age:long) 
[ 
	"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-to-table edges with_source_id=SourceId with_target_id=TargetId

輸出

SourceId TargetId 來源 目的地 edge_type
-3122868243544336885 -7133945255344544237 Alice Bob communicatesWith
-3122868243544336885 2533909231875758225 Alice 特 倫 特 信託
-7133945255344544237 2533909231875758225 Bob 特 倫 特 hasPermission
4363395278938690453 -3122868243544336885 Eve Alice attacks
3855580634910899594 -3122868243544336885 馬婁裡 Alice attacks
3855580634910899594 -7133945255344544237 馬婁裡 Bob attacks

取得節點

在此範例中,運算符會將 graph-to-table 節點從圖形匯出至數據表。 參數會 with_node_id 匯出節點哈希。

let nodes = datatable(name:string, type:string, age:long) 
[ 
	"Alice", "Person", 23,  
	"Bob", "Person", 31,  
	"Eve", "Person", 17,
	"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-to-table nodes with_node_id=NodeId

輸出

NodeId NAME type 年齡
-3122868243544336885 Alice 個人 23
-7133945255344544237 Bob 個人 31
4363395278938690453 Eve 個人 17
2533909231875758225 特 倫 特 系統 99
3855580634910899594 馬婁裡

取得節點和邊緣

在此範例中,運算符會將 graph-to-table 節點和邊緣從圖形匯出至數據表。

let nodes = datatable(name:string, type:string, age:long) 
[ 
	"Alice", "Person", 23,  
	"Bob", "Person", 31,  
	"Eve", "Person", 17,
	"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-to-table nodes as N with_node_id=NodeId, edges as E with_source_id=SourceId;
N; 
E

輸出數據表 1

NodeId NAME type 年齡
-3122868243544336885 Alice 個人 23
-7133945255344544237 Bob 個人 31
4363395278938690453 Eve 個人 17
2533909231875758225 特 倫 特 系統 99
3855580634910899594 馬婁裡

輸出數據表 2

SourceId 來源 目的地 edge_type
-3122868243544336885 Alice Bob communicatesWith
-3122868243544336885 Alice 特 倫 特 信託
-7133945255344544237 Bob 特 倫 特 hasPermission
4363395278938690453 Eve Alice attacks
3855580634910899594 馬婁裡 Alice attacks
3855580634910899594 馬婁裡 Bob attacks