Fall 2018

COMP 755

Programming Assignment

Background: Complement graph

From Wikipedia, the free encyclopedia

The (on the left) and its complement graph (on the right).

In , the complement or inverse of a graph G is a graph H on the same vertices such that two vertices of H are adjacent if and only if they are not adjacent in G. That is, to generate the complement of a graph, one fills in all the missing edges required to form a , and removes all the edges that were previously there. It is not, however, the set complement of the graph; only the edges are complemented. Formal construction

Let G = (V, E) be a simple graph and let K consist of all 2-element subsets of V. Then H = (V, K \ E) is the complement of G.

Adjacency matrix

From Wikipedia, the free encyclopedia

In mathematics and computer science, an is a means of representing which vertices (or nodes) of a graph are adjacent to which other vertices. Another matrix representation for a graph is the incidence matrix. Specifically, the adjacency matrix of a finite graph G on n vertices is the n × n matrix where the non-diagonal entry aij is the number of edges from vertex i to vertex j, and the diagonal entry aii, depending on the convention, is either once or twice the number of edges (loops) from vertex i to itself. Undirected graphs often use the latter convention of counting loops twice, whereas directed graphs typically use the former convention. There exists a unique adjacency matrix for each isomorphism class of graphs (up to permuting rows and columns), and it is not the adjacency matrix of any other isomorphism class of graphs. In the special case of a finite simple graph, the adjacency matrix is a (0,1)-matrix with zeros on its diagonal. If the graph is undirected, the adjacency matrix is symmetric.

Problem 1: Write a concurrent version of this program using Pthreads. This program will calculate the complement of a given simple graph. The input for this program will be from a text file. The name of the file will be graph.txt and will be in your pgm directory.

Example Input:

4

0 1 1 0

1 0 0 1

1 0 0 1

0 1 1 0

Example Output:

0 0 0 1

0 0 1 0

0 1 0 0

1 0 0 0

Your program should be named pcom.cpp and be placed in your pgm directory for grading.

This program is due:

Wednesday, Oct 3rd at 11 PM.