База данных графов DEX с C#: есть ли примеры кода для экспорта графов?

Я начал использовать базу данных DEX Graph с C#. До сих пор мне удавалось запускать простые примеры, но я не могу понять, как экспортировать график.

Я хотел бы экспортировать график в формат Graphviz, чтобы отображать его с помощью других инструментов визуализации. Кто-нибудь знает какой-нибудь хороший ресурс, где можно найти пример экспорта графа, или, возможно, кто-то из вас уже успел экспортировать граф и может поделиться кодом?

Я был бы очень благодарен за вашу помощь.


person Niko Gamulin    schedule 01.06.2012    source источник


Ответы (2)


Существует простой экспортер по умолчанию, который можно использовать следующим образом:

DefaultExport exp = new DefaultExport();
graph.Export("exported.gv", ExportType.Graphviz, exp);

Но для получения более качественных результатов вам может потребоваться написать свой собственный экспортер, расширяющий 1sparsity

DefaultExport exp = new DefaultExport();
graph.Export("exported.gv", ExportType.Graphviz, exp);
1dex
DefaultExport exp = new DefaultExport();
graph.Export("exported.gv", ExportType.Graphviz, exp);
1gdb
DefaultExport exp = new DefaultExport();
graph.Export("exported.gv", ExportType.Graphviz, exp);
1ExportManager.html" rel="nofollow" >ExportManager
класс.

И вы можете задать вопрос на форуме компании, если у вас возникнут проблемы.

person Jar Jar Binks    schedule 01.06.2012

Чтобы сделать свой собственный экспортер, вы должны сделать что-то вроде этого:

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;
        }
    } 

Боюсь, что для графвиза экспортер принимает только смену лейблов. Для цветов и форм ... может быть, вы можете рассмотреть возможность экспорта ygraphml?

person Damaris    schedule 04.06.2012