Implementation doubt

Not getting idea about how to implement it. I know that if 2 nodes are not connected then they must be assigned x and z respectively.

First observation is that, if two nodes, u and v are not connected, then one of them is ā€œxā€ and another one is ā€œzā€. Second observation is that if is a set of nodes with value ā€œxā€, and set is a set of nodes with value ā€œzā€, then interchanging them will not change the encrypted graph, i.e. assign value ā€œzā€ to set and value ā€œxā€ to set . So first we will search for a pair of nodes, u and v , which are not connected, assign one of them to ā€œxā€ and another to ā€œzā€. Now for the rest of the nodes, if a node, w is connected to both u and v , assign value ā€œyā€ to it. If a node, w is connected to node u only, then assign value ā€œxā€ to it. If a node, w is connected to node v only, then assign value ā€œzā€ to it. Now since you have assigned values to all of the nodes, for every pair of nodes, check whether it satisfies the rules of encryption. If it does not, then answer is NO.

The code to implement this https://ide.codingblocks.com/s/340582