Skip to content

LxLeChat/DotNetGraph

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DotNetGraph

Create DOT/GraphViz diagram using C# / .Net

Available on NuGet: #

Documentation

Create a graph (DotGraph)

var graph = new DotGraph("MyGraph");

var directedGraph = new DotGraph("MyDirectedGraph", true);

Create and add a node (DotNode)

var myNode = new DotNode("MyNode") {
    // Set all available properties
    Shape = DotNodeShape.Ellipse,
    Label = "My node !",
    FillColor = DotColor.Lightgrey,
    FontColor = DotColor.Black,
    Style = DotNodeStyle.Default,
    Height = 0.5f
};

// Add the node to the graph
graph.Add(myNode);

Create and add an arrow (DotArrow)

// Create an arrow with node names
var myArrow = new DotArrow("myNode1", "myNode2");

// Create an arrow with node objects
var myArrow = new DotArrow(myNode1, myNode2) {
    // Set all available properties
    ArrowHeadShape = DotArrowShape.Normal;
};

// Add the arrow to the graph
graph.Add(myArrow);

Compile to DOT format

// Indented version
var dot = graph.Compile(false);

// Minified version
var dot = graph.Compile();

// Save it to a file
File.WriteAllText("myFile.dot", dot);

About

Create DOT diagram using C#

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%