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?
Merge pull request #317 from serval2412/master

Fix some cppcheck warnings