Complete rewrite of Graph class and components

The code has been refactored with separation of files and added edge
knowledge to nodes.