some graph algorithm implements