The description of the question is the following.
A program would read a file by lines to build up a graph. Each line in the file would be one of theses three kinds of operations:
- add x y, which means adding an edge between node x and y,so that a graph would be formed. This graph is a undirected graph.
- remove x y, which means removing an edge between node x and y, if it's not valid(x or y does not appear to exist in graph or not edges exists between x and y), then do nothing.
- is linked x y, which should return if x and y can be connected through all the edges in the graph. The time complexity of this operation should be constant time.
Here is an example:
   add 1 2  
   add 2 3
   is linked 1 3(should be true ,cause there is a path 1-> 2, 2->3)
   add 3 4
   remove 2 3
   is linked 1 4(should be false)
 
     
    