GeeksforGeeks » C/C++ Programming Questions

complement of two graphs in c

(1 post)
  • Started 5 months ago by bkafroboy69

Tags:

  1. bkafroboy69
    Member
    Posted 5 months ago #

    Wikipedia says that “In graph theory, 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 find the complement of a graph, you fill in all the missing edges to get a complete graph, and remove all the edges that were already there. It is not the set complement of the graph; only the edges are complemented.” For example, each of the following two graphs is complement of the other.

    Now you are asked to implement a function that takes two graphs represented by adjacency matrices as parameters and checks if they are complement of each other. If so it returns 1; otherwise, returns 0.
    #define MAXV 6 /* for the above graph but can be changed for others */
    int check_if_complement(int G[MAXV+1][MAXV+1], int H[MAXV+1][MAXV+1])
    {


Reply

You must log in to post.

RSS feed for this topic