Created
April 10, 2022 22:39
-
-
Save ckampfe/41a4fc8d7e888b8d11098db50a8ce952 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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