Skip to content

Commit

Permalink
Expand the directed graph example to include dropping edges and nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
CFiggers committed Jul 9, 2024
1 parent b3dbe76 commit 5a42d2e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/02-directed-graph.janet
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,11 @@
(printf "does the graph contain the newly added node? %q" (:contains *graph* :c2))
(printf "neighbors for node C: %q" (:neighbors *graph* :c))

# you can also remove the nodes or edges if you don't want them any more
(:drop-edge *graph* :c2)
(printf "neighbors for node C are different now: %q" (:neighbors *graph* :c))
(:drop-node *graph* :c2)
(printf "does the graph contain the previously added node? %q" (:contains *graph* :c2))

# you can even find the path (really the edges) from one node to another
(printf "edges to get from node A to node I: %q" (:find-path *graph* :a :i))

0 comments on commit 5a42d2e

Please sign in to comment.