implemented networkx graph structure