Refactor Graph::build() to reduce complexity. Various PHPdoc improvements.