Computer Science Notes

Notes From CS Undergrad Courses FSU

This project is maintained by awa03

Terminology

Cycles

Representation of Graphs

Adjacency matrix

Topological Sorting

void Graph()::topsort{
	for(int counter = 0; counter < NUM_VERT; counter++){
		Vertex v - findNewVertexOfIndegreeZero();
		if(v == NOT_A_VERTEX){
			throw CycleFoundException()
		}
		v.topNum = counter;
		for each Vertex w adjacent to v
			w.indegree--;
	}
}

void Graph::topsort(){
	Queue<Vertex> q;
	int counter = 0;
	q.makeEmpty();
	for each Vertex v
		if( v.indegree == 0){
			q.dequeue(v);
		}
	while(!q.isEmpty){
		Vertex v = q.dequeue();
		v.topNum ++counter;
	for each Vertex w adjacent to v
		if(--w.indegree == 0)
			// Etc
	}
}

Single Source Shortest Path Problem