# Define single source shortest path problem

## online dating website to buy

(array-ref (C G) (list i j)) gives the cost from i to j in G, and is computed as the Euclidean distance using x-vect and y-vect. ((draw-edge G) edge) where edge is a pair, such as (list i j)).

If the edge (i j) does not exist then then (array-ref (C G) (list i j)) is *max*. It should be noted that the functions draw-vertex and draw-edge are "partially applicable" and can therefore be "curried" thus allowing us to use the primitive ``for-each''.

We might then want to know, given a city called Source, what is the distance from Source to i, for all i not equal to Source. An algorithm that does this is The algorithm uses the following variable S, the set of ``special'' vertices, such that all vertices in S are already on shortest paths V-S (read it as V minus S) the set of vertices not in S D a vector, such that D[i] is the distance from Source to i (and initially D is a copy of the Source'th row in (C G)) P a vector, such that P[i] is the vertex immediately before vertex i on the path from Source The algorithm goes like this: 1. add u to the set S, and remove u from the set V-S 3. We will have an object called a graph G, where the graph may be directed or undirected.

The (directed) graph object can be created using the function call: where n is the size of the graph (number of vertices) and p is the probability that an edge exists between vertices i and j, for all i and all j, where i is not equal to j.

(y-vect G) A vector, where (vector-ref (y-vect G) i) gives the y coordinate of vertex i.

Consequently x-vect and y-vect give the position of the vertices in the x-y plane (C G) Is the cost matrix for the graph G.

Therefore, the diagonal (for the non-existent edges (i i)) will have all elements set to *max* There are functions to save graphs to disc (ie. For example, given graph G we can draw all of the edges of G as follows: There are also functions (as you could expect) to determine if G is a graph (graph?

(save-graph G fname)) and to load graphs from disc (ie. G), test if vertex i is adjacent to vertex j in G (adjacent?Basic definition of a graph = (V, E), where the graph G is composed of a set of vertices V (also known as nodes) and a set of undirected edges E.Edges may be "labelled" with something, such as a cost, where cost may be a distance between vertices, time between vertices, cost in going between vertices, etc. Alternatively, edges maybe labelled with relations, such as before/after, , and so on.In save the immediate predecessor of the shortest path from i to j. If you have suggestions, corrections, or comments, please get in touch with Paul Black. Suppose predecessor[i][j] is k; then the shortest path ends with ... If predecessor[i][k] is p, the shortest path ends with ... With the adjacency list we associate with each vertex a list, containing the vertices adjacent to that vertex.