如何在 dotNetRDF 库中使用 GraphVizWriter?

发布于 2024-12-10 17:04:46 字数 1950 浏览 0 评论 0原文

我想知道应该编写什么语法来使用 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 文件格式,然后我想以图形方式显示我的图表

I want to know what syntax should I write to use GraphVizWriter to show my graph in a png format ?

I use dotNetRDF library.

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

    }

first i read an n3 file format and then i wand to show my graph graphicaly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空名 2024-12-17 17:04:46

它看起来不像 dotNetRDF 直接生成 png 输出。上述类输出点文件。

来自库文档

从 RDF 图表生成 GraphViz DOT 格式文件的编写器

您必须使用 Graphviz。

It doesn't look like dotNetRDF produces png output directly. The mentioned class outputs dot files.

From the documentation of the library:

A Writer which generates GraphViz DOT Format files from an RDF Graph

You'd have to take the output and generate an actual image using Graphviz.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文