Skip to content

Instantly share code, notes, and snippets.

@ckampfe
Created April 10, 2022 22:39
Show Gist options
  • Save ckampfe/41a4fc8d7e888b8d11098db50a8ce952 to your computer and use it in GitHub Desktop.
Save ckampfe/41a4fc8d7e888b8d11098db50a8ce952 to your computer and use it in GitHub Desktop.
g = :digraph.new()
v1 = :digraph.add_vertex(g, "v1")
v2 = :digraph.add_vertex(g, "v2")
v3 = :digraph.add_vertex(g, "v3")
v4 = :digraph.add_vertex(g, "v4")
:digraph.add_edge(g, v2, v1)
:digraph.add_edge(g, v3, v2)
:digraph.add_edge(g, v4, v2)
IO.inspect(:digraph.get_path(g, v4, v1))
IO.inspect(:digraph.get_path(g, v1, v4))
IO.inspect(:digraph_utils.topsort(g))
$ elixir graph_stuff.exs
["v4", "v2", "v1"]
false
["v3", "v4", "v2", "v1"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment