Skip to content

Instantly share code, notes, and snippets.

@lildata
Last active August 29, 2015 14:25
Show Gist options
  • Save lildata/54ff6537f99432be1615 to your computer and use it in GitHub Desktop.
Save lildata/54ff6537f99432be1615 to your computer and use it in GitHub Desktop.
user=> (def g1 (weighted-digraph [:usr.1 :bro.1 1] [:usr.1 :itr.1 1] [:bro.1 :itr.1 0.5] [:itr.1 :prm.1 1] [:itr.1 :prm.2 1] [:usr.1 :bro.2 1] [:bro.2 :itr.2 1] [:itr.2 :prm.2 1]))
#'user/g1
user=> (shortest-path g1 :usr:1 :prm:2)
nil
user=> (shortest-path g1 :usr.1 :prm.2)
(:usr.1 :itr.1 :prm.2)
user=> (bellman-ford g1 :usr.1)
[{:itr.2 2, :itr.1 1, :bro.1 1, :prm.2 2, :bro.2 1, :prm.1 2, :usr.1 0} {:usr.1 (:usr.1), :prm.1 (:usr.1 :itr.1 :prm.1), :bro.2 (:usr.1 :bro.2), :prm.2 (:usr.1 :itr.1 :prm.2), :bro.1 (:usr.1 :bro.1), :itr.1 (:usr.1 :itr.1), :itr.2 (:usr.1 :bro.2 :itr.2)}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment