如何在dotNetRDF库中使用GraphVizWriter?

时间:2011-10-17 09:12:39

标签: .net graphviz n3 dotnetrdf

我想知道我应该编写什么语法来使用GraphVizWriter以png格式显示我的图形?

我使用dotNetRDF库。

private void button1_Click(object sender, EventArgs e)
    {

        Stream myStream = null;

        var parser = new Notation3Parser();
        var graph = new Graph();
        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        openFileDialog1.Filter = "RDF files (*.n3)|*.n3";
        openFileDialog1.FilterIndex = 1;
        openFileDialog1.RestoreDirectory = true;
        openFileDialog1.Multiselect = false;

        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            try
            {
                if ((myStream = openFileDialog1.OpenFile()) != null)
                {
                    using (myStream)
                    {
                        string s = openFileDialog1.FileName.ToString();
                        string w= Directory.GetCurrentDirectory().ToString();
                        string Fname = openFileDialog1.SafeFileName.ToString();
                        File.Copy(s,Path.Combine(w,Fname),true);
                        Win32.AllocConsole();
                        s1 = Path.Combine(w, Fname);

                        showPath.Text = s1;
                        String parentvalueadress = this.s1;
                        showPath.Visible = true;
                        insertNodeButton.Visible = true;
                        delBut.Visible = true;


                        showNodes showNodes1 = new showNodes(s1);
                        g = showNodes1.returngraph();

                       Console.Read();
                       Win32.FreeConsole();


                       this.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
            }
        }

    }

首先我读了一个n3文件格式,然后我用魔杖显示我的图形图像

1 个答案:

答案 0 :(得分:1)

看起来dotNetRDF不直接产生png输出。提到的类输出点文件。

来自documentation of the library

  

从RDF图生成GraphViz DOT格式文件的Writer

您必须使用Graphviz获取输出并生成实际图像。