Find no path between nodes

Write a program that does the following:
Accept the following inputs:
(1) Number of nodes
(2) A 2-D array representing edges. ith edge connects node input2[0][i] to node input2[1][i].
Assuming that a line can be drawn between nodes if there is an edge between them, print number of lines that can be drawn between nodes.

Sample test case:
input1: 4
input2: {{1,1,1},{2,3,4}}
output1: 3