我開始在C#中使用DEX Graph數據庫。到目前爲止,我已經設法運行簡單的示例,但無法找出如何導出圖形。DEX圖形數據庫與C#:有沒有任何代碼示例圖導出?
我想將圖表導出爲Graphviz格式以便與其他可視化工具一起顯示。有沒有人知道任何好的資源,哪裏可以找到圖表導出的例子,或者可能有人已經設法導出圖表並共享代碼?
我會非常感謝您的幫助。
我開始在C#中使用DEX Graph數據庫。到目前爲止,我已經設法運行簡單的示例,但無法找出如何導出圖形。DEX圖形數據庫與C#:有沒有任何代碼示例圖導出?
我想將圖表導出爲Graphviz格式以便與其他可視化工具一起顯示。有沒有人知道任何好的資源,哪裏可以找到圖表導出的例子,或者可能有人已經設法導出圖表並共享代碼?
我會非常感謝您的幫助。
有可以使用這樣一個簡單的默認出口:
DefaultExport exp = new DefaultExport();
graph.Export("exported.gv", ExportType.Graphviz, exp);
但要獲得更好的輸出,你可能需要編寫自己的出口擴展ExportManager類。
如果您有問題,您可以在公司forum詢問。
爲了使自己的出口,你應該做這樣的事情:
public class MyExport : ExportManager
{
private Graph g = null;
public MyExport() {
}
public override void Prepare(Graph graph) {
// This method will be called once at the beginning of the export.
// So we keep the graph being exported.
g = graph;
}
public override void Release() {
// Called once at the end of the export process.
}
public override bool GetGraph(GraphExport graphExport) {
// Called once to get the Graph details (a label)
graphExport.SetLabel("[MyExport] MyGraph");
return true;
}
public override bool EnableType(int type) {
// Will be called once for each type to allow or deny the export of
// the nodes/edges of each type
return true; // We enable the export of all types
}
public override bool GetNode(long node, NodeExport nodeExport) {
// Called once for each node of an allowed type to get it's export definition.
// The definition will be used if it returns true, or the default
// node type definition from getNodeType will be used if this method
// returns false.
// It can set the label, shape, color, ...
nodeExport.SetLabel("[MyExport] MyNode " + node);
return true;
}
public override bool GetNodeType(int type, NodeExport nodeExport) {
// Used to get a node type generic export definition.
// Called once for each node only if the call to GetNode returned false.
// It can set the label, shape, color, ...
nodeExport.SetLabel("[MyExport] MyNodeType " + type);
return true;
}
public override bool GetEdge(long edge, EdgeExport edgeExport) {
// Called once for each edge of an allowed type to get it's export definition.
// The definition will be used if it returns true, or the default
// edge type definition from getEdgeType will be used if this method
// returns false.
// It can set the label, shape, color, ...
edgeExport.SetLabel("[MyExport] MyEdge " + edge);
return true;
}
public override bool GetEdgeType(int type, EdgeExport edgeExport) {
// Used to get an edge type generic export definition.
// Called once for each edge only if the call to GetEdge returned false.
// It can set the label, shape, color, ...
edgeExport.SetLabel("[MyExport] MyEdgeType " + type);
return true;
}
}
恐怕對graphviz的出口只接受改變標籤。對於顏色和形狀,...也許你可以考慮使用ygraphml輸出?