Two graphs G_1 and G_2 are said to be isomorphic
if we can find a one-to-one mapping of vertex index vG_1i --> vG_2map(i)
where haveEdgeG_1(i,j) = haveEdgeG_2(map(i),map(j)).
Your job is to figure out whether two given undirected graphs are isomorphic or not.
The first line contains T<50, indicating the number of test cases.
Every case begins with n<50, m, where n denotes the number of vertices in both graphs and m denotes the number of edges in both graphs. Each of the following m lines contains 2 numbers a_1, a_2, denoting there is an edge between the two nodes a_1 and a_2 in graph G_1. The last m lines are of the same format but representing G_2.
For each case, output "Yes" if the two graphs are isomorphic, or "No" otherwise.
2 3 2 0 1 0 2 2 0 2 1 4 4 0 1 1 2 2 3 3 0 0 1 1 2 2 3 2 0
Yes No
Migrated from old NTUJ.
pP
No. | Testdata Range | Score |
---|