change mbgraph. Create pointer. Refactor algorithms