Directed Graph
- Draw a tree as directed graph.
::
let edges = matrix<Int64>([
[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7],
[1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14],
[14, 15], [14, 16], [14, 17], [14, 18], [14, 19]
])
digraph(edges)
Result:
.. image:: ../../../tests/imgs/graph/digraph1.png :align: center :width: 360
- Draw a cube as directed graph.
::
let edges = matrix<Int64>([
[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 4],
[2, 6], [3, 5], [3, 6], [4, 7], [5, 7], [6, 7]
])
var g = digraph(edges)
g.edge_labels(["x", "y", "z", "y", "z", "x", "z", "x", "y", "z", "y", "x"])
g.node_labels(["{0}", "{x}", "{y}", "{z}", "{x,y}", "{x,z}", "{y,z}", "{x,y,z}"])
Result:
.. image:: ../../../tests/imgs/graph/digraph2.png :align: center :width: 360