When you are tuning spanning tree topology, to force a port into blocking or forwarding mode.
Increasing the port cost on a switch makes it less desirable for that switch and if its cost is higher than the current route, this port will move from forwarding to blocking.
p19s3#sh spanning-tree vlan 4 | i Int
Interface Fa0/3 (port 15) in Spanning tree 4 is FORWARDING
Interface Fa0/5 (port 17) in Spanning tree 4 is BLOCKING
Interface Fa0/6 (port 18) in Spanning tree 4 is BLOCKING
p19s3(config-if)#int f0/3
p19s3(config-if)#spanning-tree vlan 4 cost 57
p19s3#sh spanning-tree vlan 4 | i Int
Interface Fa0/3 (port 15) in Spanning tree 4 is BLOCKING
Interface Fa0/5 (port 17) in Spanning tree 4 is LISTENING
Interface Fa0/6 (port 18) in Spanning tree 4 is BLOCKING
By looking at the network topology you can count the hops to the root through the path you prefer, and set the cost of the current port forwarding traffic to a higher value.
Each hop cost is different depending on the link speed.
MST configured switches represent one giant virtual switch so you do not need to count hops inside MST.
Increasing the port cost on a switch makes it less desirable for that switch and if its cost is higher than the current route, this port will move from forwarding to blocking.
p19s3#sh spanning-tree vlan 4 | i Int
Interface Fa0/3 (port 15) in Spanning tree 4 is FORWARDING
Interface Fa0/5 (port 17) in Spanning tree 4 is BLOCKING
Interface Fa0/6 (port 18) in Spanning tree 4 is BLOCKING
p19s3(config-if)#int f0/3
p19s3(config-if)#spanning-tree vlan 4 cost 57
p19s3#sh spanning-tree vlan 4 | i Int
Interface Fa0/3 (port 15) in Spanning tree 4 is BLOCKING
Interface Fa0/5 (port 17) in Spanning tree 4 is LISTENING
Interface Fa0/6 (port 18) in Spanning tree 4 is BLOCKING
By looking at the network topology you can count the hops to the root through the path you prefer, and set the cost of the current port forwarding traffic to a higher value.
Each hop cost is different depending on the link speed.
MST configured switches represent one giant virtual switch so you do not need to count hops inside MST.

