Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 22nd, 2012  |  syntax: None  |  size: 2.81 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. DEX Graph Database with C#: Are there any code examples for graph export?
  2. DefaultExport exp = new DefaultExport();
  3. graph.Export("exported.gv", ExportType.Graphviz, exp);
  4.        
  5. public class MyExport : ExportManager
  6.     {
  7.         private Graph g = null;
  8.  
  9.         public MyExport() {
  10.         }
  11.  
  12.         public override void Prepare(Graph graph) {
  13.             // This method will be called once at the beginning of the export.
  14.             // So we keep the graph being exported.
  15.             g = graph;
  16.  
  17.         }
  18.  
  19.         public override void Release() {
  20.             // Called once at the end of the export process.
  21.         }
  22.  
  23.         public override bool GetGraph(GraphExport graphExport) {
  24.             // Called once to get the Graph details (a label)
  25.             graphExport.SetLabel("[MyExport] MyGraph");
  26.             return true;
  27.         }
  28.  
  29.         public override bool EnableType(int type) {
  30.             // Will be called once for each type to allow or deny the export of
  31.             // the nodes/edges of each type
  32.             return true; // We enable the export of all types
  33.         }
  34.  
  35.  
  36.         public override bool GetNode(long node, NodeExport nodeExport) {
  37.             // Called once for each node of an allowed type to get it's export definition.
  38.             // The definition will be used if it returns true, or the default
  39.             // node type definition from getNodeType will be used if this method
  40.             // returns false.
  41.             // It can set the label, shape, color, ...
  42.             nodeExport.SetLabel("[MyExport] MyNode " + node);
  43.             return true;
  44.         }
  45.  
  46.         public override bool GetNodeType(int type, NodeExport nodeExport) {
  47.             // Used to get a node type generic export definition.
  48.             // Called once for each node only if the call to GetNode returned false.
  49.             // It can set the label, shape, color, ...
  50.             nodeExport.SetLabel("[MyExport] MyNodeType " + type);
  51.             return true;
  52.         }
  53.  
  54.         public override bool GetEdge(long edge, EdgeExport edgeExport) {
  55.             // Called once for each edge of an allowed type to get it's export definition.
  56.             // The definition will be used if it returns true, or the default
  57.             // edge type definition from getEdgeType will be used if this method
  58.             // returns false.
  59.             // It can set the label, shape, color, ...
  60.             edgeExport.SetLabel("[MyExport] MyEdge " + edge);
  61.             return true;
  62.         }
  63.  
  64.         public override bool GetEdgeType(int type, EdgeExport edgeExport) {
  65.             // Used to get an edge type generic export definition.
  66.             // Called once for each edge only if the call to GetEdge returned false.
  67.             // It can set the label, shape, color, ...
  68.             edgeExport.SetLabel("[MyExport] MyEdgeType " + type);
  69.             return true;
  70.         }
  71.     }