Let's begin with an example. Assuming that LINK has been properly
installed on your system, you can start it by typing Link
at the command line prompt of your operating system (or by
double-clicking the appropriate icon). You may now enter commands
and start building graphs. This tutorial will give you several
examples so that you can get started right away. When you need to
learn the system more thoroughly, the later chapters will provide
much more detail.
Our first example is shown in
Figure .
A graph without any vertices isn't much fun, so let's add some
vertices. Link allows you to name your vertices with integers,
symbols, or character strings. The example in
Figure shows
the addition of three vertices, one with each type of name.
Of course, it might be quite inconvenient to have to add each vertex
individually if we want to build a big graph. One solution to this
problem is to use the
add-vertices!
command shown in
Figure .
Another solution to this problem, and one which will be the
solution to many problems, is to use the Scheme command language.
We can write a short program to add our vertices for us.
Now that we have given our graph some vertices, it is time to add edges. An edge is a collection of vertices. The only type of edge we will discuss here has exactly two vertices, and there is no ordering of the vertices. Such an edge is usually drawn as a line connecting the two vertices. Our next task will be to construct some edges from the vertex set.
First, we must obtain the vertex set from the graph so that we can
pick out the vertices we want for our edges. The vertex set of a
graph is returned by the vertices function. This is shown in
Figure . The figure also shows the construction
of
, which is a set containing every subset of the vertex
set V which has size 2. This set represents all possible lines
connecting vertices in our graph.