簡體   English   中英

敏捷圖數據庫檢索所有節點和邊

[英]Dex graph database retrieve all nodes and edges

我知道如何將圖形數據庫輸出到文件(如GraphML文件),但是我寧願遍歷節點並將它們作為C#對象,因為我需要在其他地方使用它們。

像這樣:

var it = graph.GetNodeIterator();
while (it.HasNext()) {
    var node = new MyNodeObject();
    //get attributes or whatever
    nodeList.Add(node);
}
//nodeList now contains all nodes in a List

我找不到方便的方法來完成此操作,並且Dex文檔不是很有幫助。 顯然,Dex有某種方法可以執行此操作,因為我可以輕松導出到GraphML,但是我不想導出到GraphML,然后將GraphML解析為C#對象。

這是我的操作方式,不確定是否是最好的方法:

//find the type(s) youre looking for based on how you assigned
//them in the first place. you may already know.
var typeIt = graph.FindTypes().Iterator();
while (typeIt.HasNext()) {
   //find your types if you dont know
}

//select the types you want. lets say all of your nodes have one of two types,
//which map to attributes 4 and 3.
var select = graph.Select(4);
//union them
select.Union(graph.Select(3));
//start to iterate
var it = select.Iterator();
while (it.HasNext()) {
    var next = it.Next();
    //map to your own objects using next
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM