The best next hop determination depends on the routing protocol used to select it.
More than one routing protocol can be running on a router at the same time (each with their own best next hops).
Once every running routing protocol decides their own next hops (they dont have to agree) each routing protocol installs one (or more) routes in the routing table.
The routing table takes the best hop with the lowest administrative distance for the most specific destination.
Overly complex and funny example:
A router is running several routing protocols and is directly connected to many other routers 1.1.1.[1-9].
On a given router RIP is running (because im assuming since you are talking about hop count, you are studying RIP)
RIP has 3 neighbors, 1.1.1.1, 1.1.1.2, and 1.1.1.3.
Each neighbor sends routes for the network 192.168.0.0/24.
1.1.1.1 has that network at 1 hop away
1.1.1.2 has that network at 2 hops away
1.1.1.3 has that network at 3 hops away
RIP decides the best next hop to 192.168.0.0/24 is 1.1.1.1 so it installs 1.1.1.1 in the routing table.
DBM (me) also hates rip, so he runs bgp and peers with his route-reflector. BGP reports the best path to 192.168.0.0/24 via 1.1.1.4. BGP decides its next best hop is 1.1.1.4 and installs that in the routing table.
HELLFIRE (who likes to troll my posts) is lazy, and doesnt want to run a routing protocol so he added a static route to the router for 192.168.0.0/16 pointing to his router 1.1.1.5.
His static route is installed into the routing table.
The routing table now looks like this:
(Static) 192.168.0.0/16 -> 1.1.1.5
(iBGP) 192.168.0.0/24 -> 1.1.1.4
(RIP) 192.168.0.0/24 -> 1.1.1.1
If a packet comes into the router destined for 192.168.0.1, which next hop would be used?
First criteria to decide: prefix length. The longer prefixes /24 are more specific than the summary HELLFIRE put into the router, so we will only consider those 2 routes (rip and ibgp)
The second criteria, is administrative distance. Admin distance is how trustworthy the routing protocol is. In this case, RIP with an AD of 120, and iBGP is 200.
Becuase RIP has the most specific prefix for the destination, and the lowest administrative distance of the equal-length prefixes, the router will forward the packet to 1.1.1.1.
I hope the example is helpful, and somewhat demeaning to hellfire =P
! We can see that the router hears about 192.168.0.0 from many rip neighbors
R1# debug ip rip
*Feb 27 13:27:52.979: RIP: received v2 update from 1.1.1.3 on Serial1/3
*Feb 27 13:27:52.983: 192.168.0.0/24 via 0.0.0.0 in 3 hops
*Feb 27 13:27:55.583: RIP: received v2 update from 1.1.1.1 on Serial1/1
*Feb 27 13:27:55.583: 192.168.0.0/24 via 0.0.0.0 in 1 hops
*Feb 27 13:28:00.895: RIP: received v2 update from 1.1.1.2 on Serial1/2
*Feb 27 13:28:00.895: 192.168.0.0/24 via 0.0.0.0 in 2 hops
...
! But rip will only install the lowest hop count in its database.
R1#show ip rip database 192.168.0.0 255.255.255.0
192.168.0.0/24
[1] via 1.1.1.1, 00:00:01, Serial1/1
! RIP installs only its best route in the routing table.
! BGP and static routes also show up because other protocols added them.
R1#show ip route | I 192.168.0.0
S 192.168.0.0/16 [1/0] via 1.1.1.5, Serial1/5
R 192.168.0.0/24 [120/1] via 1.1.1.1, 00:00:00, Serial1/1
B 192.168.0.0/24 [200/0] via 1.1.1.4, 00:00:00, Serial1/4
! Less specific packets will goto HELLFIREs router
R1#show ip route 192.168.1.0
Routing entry for 192.168.0.0/16, supernet
Known via "static", distance 1, metric 0
Routing Descriptor Blocks:
* 1.1.1.5, via Serial1/5
Route metric is 0, traffic share count is 1
! But the most specific route will go via RIP.
R1#show ip route 192.168.0.0
Routing entry for 192.168.0.0/24
Known via "rip", distance 120, metric 3
Redistributing via rip
Last update from 1.1.1.1 on Serial1/1, 00:00:10 ago
Routing Descriptor Blocks:
* 1.1.1.1, from 1.1.1.1, 00:00:10 ago, via Serial1/1
Route metric is 1, traffic share count is 1
*actual output may be fudged for effect. I had distribute-lists slapped everywhere to force the advertisments to show up (split horizon, other loop prevention and path muckery)