quartz/content/notes/20-graphs-2.md
Jet Hughes 0324a7cb71 update
2022-06-08 14:12:07 +12:00

1.1 KiB

title aliases tags sr-due sr-interval sr-ease
20-graphs-2
cosc201
lecture
2022-06-26 23 250

Graph drawing is its own problem.

One easy way is to draw the vertices is clockwise order and draw edges between them

traversal examples

recurisve depth first traversal

same but.. delay the pop of an item from the stack until all its neighbours have been processed, and we only push those one at a time.

code

topological sorting

In a directed graph we have edges from v to w which do not necessarily imply an edge from w to v.

then is a neighbor of v but not (necessarily) vice versa.

suppose edges indicate some dependency

we want an order of vertices that finishes with v but never containes any vertex unless all the things that depend on it occur earlier

this is a (reverse) topological sort

for this to work the graph must be acyclic. i.e., we cannot have a depends on v which depends on w which depends on a

it that condition is met a recursive depth first traversal can be used.3