  Two-sample tests for multivariate data and non-Euclidean data are widely used
in many fields. Parametric tests are mostly restrained to certain types of data
that meets the assumptions of the parametric models. In this paper, we study a
nonparametric testing procedure that utilizes graphs representing the
similarity among observations. It can be applied to any data types as long as
an informative similarity measure on the sample space can be defined. The
classic test based on a similarity graph has a problem when the two sample
sizes are different. We solve the problem by applying appropriate weights to
different components of the classic test statistic. The new test exhibits
substantial power gains in simulation studies. Its asymptotic permutation null
distribution is derived and shown to work well under finite samples,
facilitating its application to large datasets. The new test is illustrated
through an analysis on a real dataset of network data.
