Graphvix
Graphviz for Elixir
Usage
- Start up a new process containing your graph
iex> {:ok, graph} = Graphvix.new- Add a single node
iex> Graphvix.add_node(graph, :start)- Add an edge between two nodes, creating the nodes if necessary
iex> Graphvix.add_edge(graph, :start, :middle)- Add a chain of connected nodes, creating any nodes and edges that do not exist
iex> Graphvix.add_chain(graph, [:middle, :denouement, :end])- Update settings to nodes and edges
iex> Graphvix.update_node(graph, :start, shape: "box")
iex> Graphvix.update_edge(graph, :denouement, :end, color: "red")- Show the internal structure of the graph
iex> Graphvix.show(graph)
%{
edges: %{
start: %{
middle: []
},
middle: %{
denouement: []
},
denouement: %{
end: [color: "red"]
}
},
nodes: %{
start: [label: "start", shape: "box"],
middle: [label: "middle"],
denouement: [label: "denouement"],
end: [label: "end"]
}
}-
Convert the graph to
.dotformat
iex> Graphvix.write(graph, :dot)
"digraph G {
end [label="end"];
denouement [label="denouement"];
middle [label="middle"];
start [label="start",shape="box"];
denouement -> end;
middle -> denouement;
start -> middle;
}"-
Write out to a
.dotfile (named āGā by default, but can take a 3rd argument as filename)
iex> Graphvix.write(graph, :file)
:ok
iex> Graphvix.write(graph, :file, "my_graph")
:ok