The tool generates a DOT (graph description) file for a tree and a graph. There are many tools like Visual Studio Code extensions, online tools like Graphviz Visual Editor or Viz.js which allow to visualize the dot format.
The code below generates the dot-file for the graph adjacency list.
var graph = new List<LinkedList<int>>() // adjacency list
{
new LinkedList<int>(new int[] {1,2}),
new LinkedList<int>(new int[] {0,3}),
new LinkedList<int>(new int[] {0}),
new LinkedList<int>(new int[] {1}),
};
await new GraphWriter("./output").WriteDotAsync(graph, "graph.dot");The code below generates the dot-file for a binary tree represented as a collection of nodes generated by any traversal algorithm. The node could have any type but must have the 'Key', 'Left' and 'Right' as properties.
var nodes = new List<Node> { node4, node3, node_1, node0, node1, node2 }; // the product of any traversal algorithm
await new BTreeWriter("./output").WriteDotAsync(nodes, "tree.dot");
