basic concepts Link to heading
- Vertices - V
- Edges - E, can be represented as {u, v}
path and walk Link to heading
- A path is an ordered sequence of edges that are distinct from one other.
- A walk is a sequence of vertices, such that any two consecutive vertices form an edge in the graph. eg: v1, v2, v4, v2 is a walk.
the difference of above two is the same edge cannot appear twice in a path
- a cycle in a graph is a path in which the extremities are identical.
extremeties of a path Link to heading
the two extreme vertices of the sequence; the two ’end’ vertices.
representing graph Link to heading
- use array
- use list
- use dictionary
dictionary combines the pros of both arrays and lists. as a rule of thumb, dictionaries should always be used if I don’t konw what I am doing.