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