graphvix v0.0.1 Graphvix

Summary

Functions

Adds a chain of nodes with connecting edges to the graph

Adds a new edge between two nodes, creating the nodes if necessary

Adds a node, if it doesn’t exist

Starts a new process for managing a digraph

Returns the contents of the graph

Updates settings for an existing edge

Update a node’s settings

Writes the graph in .dot format

Writes the graph in .dot format to a file

Functions

add_chain(graph, nodes)

Adds a chain of nodes with connecting edges to the graph

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.add_chain(graph, [:start, :middle, :end])
iex> g = Graphvix.show(graph)
iex> g.nodes |> Enum.count
3
iex> g.edges |> Enum.count
2
add_edge(graph, start_node, end_node)

Adds a new edge between two nodes, creating the nodes if necessary

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.add_node(graph, :start)
iex> Graphvix.add_edge(graph, :start, :end)
iex> Graphvix.show(graph)
%{
  edges: %{
    start: %{end: []}
  },
  nodes: %{
    start: [label: "start"],
    end: [label: "end"]
  }
}
add_node(graph, node)

Adds a node, if it doesn’t exist

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.add_node(graph, :start)
iex> Graphvix.show(graph)
%{nodes: %{start: [label: "start"]}, edges: %{}}
new()

Starts a new process for managing a digraph

Examples

iex> {:ok, graph} = Graphvix.new
iex> is_pid(graph)
true
show(graph)

Returns the contents of the graph

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.show(graph)
%{nodes: %{}, edges: %{}}
update_edge(graph, start_node, end_node, settings)

Updates settings for an existing edge

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.add_edge(graph, :start, :end)
iex> Graphvix.update_edge(graph, :start, :end, color: "red")
iex> g = Graphvix.show(graph)
iex> g.edges
%{
  start: %{
    end: [color: "red"]
  }
}
update_node(graph, node, settings)

Update a node’s settings

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.add_node(graph, :start)
iex> Graphvix.update_node(graph, :start, color: "red")
iex> Graphvix.show(graph)
%{nodes: %{start: [label: "start", color: "red"]}, edges: %{}}
write(graph, atom)

Writes the graph in .dot format.

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.write(graph, :dot)
~s/digraph G {\n\n\n\n}/
write(graph, atom, filename \\ "G")

Writes the graph in .dot format to a file.

Examples

iex> {:ok, graph} = Graphvix.new
iex> Graphvix.write(graph, :file)
:ok