A graph is a common Abstract Data Type used to represent
many models: it is a finite set of points connected or
unconnected by lines.
Example: A good example of a graph is cities and the transport
routes between the cities.
Notice that Hobart and Launceston are part of one graph but
are not connected to other links. This would be true in reality
if we were concerned with Rail transport.
Note we can only go in one direction on certain links:
once we have logged off, we can only login again.
Also we cannot login twice on the one terminal.
This is called a directed graph or digraph.
(An operating system is a huge state machine.)
This is for a directed graph.
Path: a sequence of vertices v1, v2, ... vn such that
Note that the geometrical representation of a graph may bear
little relationship to its mathematical nature.
I could put Hobart next to Perth and Sydney south of Melbourne.
A graph just tells us vertices(and their labels)
and arcs (and their weights).
Connected/Unconnected: A graph is connected if there is a path from every node to every other node. An unconnected graph has no paths from every node to every other node.
Trees: A graph with no cycles is a tree. A tree has a node plus zero or more children. Therefore there is only one path between any two nodes in a tree.
If we add an edge to a complete tree, it must form a cycle.