You need to assign each city with an integer value from 1 to n, where each value can only be used once. The importance of a road is then defined as the sum of the values of the two cities it connects.
A guide to Java method invocation basics, explaining what happens when you call a Java method, method signatures, pass-by-value, stack vs. heap memory and more.