void depthFirstSearch(vertex v, bool visited[n])
cfw_
vertex w;
visited[index(v)] = true;
for each vertex w for which (v,w) is an edge
if (!visited[w])
depthFirstSearch(w, visited);
void DFS()
cfw_
bool visited[n] = cfw_false;
for each vertex v with (vis
float alpha(vector X, vector Y) /
cfw_
/
float p = 0.0F;
/
int n = X.length;
/
if (n != Y.length)
return 0.0F;
else
cfw_
for (int i = 0; i < n; i+)
p += X[i]*Y[i];
return p;
Assume that the "vector" type has been
defined to be a one-dimensional array
of
void Dijkstra(vertex v, graph G)
cfw_
bool finalized[NBR_VERTICES];
float dist[NBR_VERTICES];
int predecessor[NBR_VERTICES];
/
/
/
/
NBR_VERTICES is the number of vertices in G.
finalized marks the finished vertices.
dist[i] = min cost between v & vertex
graph.h
graph.cpp
typedef int* IntArrayPtr;
/ Defined within graph.h
IntArrayPtr *adjacencyMatrix;
int numberOfVertices;
/ Graph data member
/ Graph data member
adjacencyMatrix = new IntArrayPtr[numberOfVertices];
for (int k = 0; k < numberOfVertices; k+