1

我能够通过命令行使用graphviz(dot.exe)生成图形文件。需要使用 Quickgraph.Graphviz 生成图形,无需安装。可能吗?

4

1 回答 1

2

这取决于您如何定义“安装”。如果您希望通过代码使用当前系统上的 dot.exe,您可以(来自我无法在线重新查找的示例):

public sealed class GraphRenderer : IDotEngine
{
    public string Run(GraphvizImageType imageType, string dot, string outputFileName)
    {
        string output = outputFileName;
        File.WriteAllText(output, dot);

        // assumes dot.exe is in the path EnvVar:
        var args = $@"{output} -Tjpg -O";
        System.Diagnostics.Process.Start("dot", args);
        return output;
    }
}

用过的:

var exportGraph = new GraphvizAlgorithm<TNode, TEdge>(graphToDraw);
exportGraph.Generate(new GraphRenderer(), "ActionGraph");

您可以使用exportGraph.FormatVertex/FormatEdge. 虽然这里我假设“点”在环境变量中,但如果安装得太多了,没有理由不能将进程指向本地文件。

于 2016-11-09T16:23:32.433 回答