Fix some cppcheck warnings

(style) Array index 'i' is used before limits check
(performance) Prefer prefix ++/-- operators for non-primitive types
(warning) Variable 'centrality' is reassigned a value before the old one has been used. 'break;' missing?