[prev] 18 [next]

Exercise 1: Canonical Edge Representation

Above mkEdge() simply puts vertices in edge in param order

Implement an edge equality check under such a scheme:

bool eqE(Edge a, Edge b) { ... }

Returns True if a == (v,w) && b == (v,w) OR a == (v,w) && b == (w,v)


Also ...

How would mkEdge() and eqE() change if

  • all edges (v,w) were created to ensure v < w