This is a problem that could be done with some type of brute-force algorithm, but I was wondering if there are some efficient ways of doing this.
Let\'s assume that
This problem can be recast in terms of graph theory. Nodes of the graph are the pairs you are given. Two nodes are connected if the pairs have a number in common. Your problem is to find a maximum independent set.
Maximum independent set is equivalent to finding a maximum clique, which is both NP-complete and "hard to approximate". However, in this particular case, the graphs are of a special type called "claw-free" (http://en.wikipedia.org/wiki/Claw-free_graph) because if a node is connected to three other nodes, at least two of those nodes must share a common number and so are themselves connected.
It turns out that for the special case of claw-free graphs, the maximum independent set problem can be solved in polynomial time: http://en.wikipedia.org/wiki/Claw-free_graph#Independent_sets.