 end
 
 defmodule Dot do
-  defp id(a), do: a
   defp extract_nodes(tree) do
     check_invalid(tree)
 

      {:graph, _meta, [attr]} -> attr
      _ -> []
    end)
    |> Enum.sort_by(&id/1)
  end

  defmacro graph(ast) do
    functions = %{:-- => true}
    tree = ast[:do]

    tree_in_block = cond do


    tree
    |> Enum.flat_map(fn
      {:--, _meta, [{from, _, _}, {to, _, nil} |[]]} -> Macro.escape([{from, to, []}])
      {:--, _meta, [{from, _, _}, {to, _, [attr]} |[]]} -> Macro.escape([{from, to, attr}])
      {:--, _meta, [a, b |[]]} -> raise ArgumentError
      _ -> []
    end)
    |> Enum.sort
  end

  defp check_invalid(tree) do
    lst = tree |> Enum.map(&Tuple.to_list/1) |> List.flatten
    lst |> Enum.any?(fn
      {:., _, _} -> raise ArgumentError
      {{:., _, _}, _, _} -> raise ArgumentError
      _ -> false
    end)
  end
