diff --git a/lang/zh/notebooks/tests/test_sp_methods.py b/lang/zh/notebooks/tests/test_sp_methods.py new file mode 100644 index 0000000..b37a3fd --- /dev/null +++ b/lang/zh/notebooks/tests/test_sp_methods.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Test networkx shortest paths methods. +Created on Tue Oct 9 14:49:09 2018 + +@author: ljia +""" + +import networkx as nx + +g = nx.Graph() +g.add_edge(1, 2) +g.add_edge(3, 2) +g.add_edge(1, 4) +g.add_edge(3, 4) +p1 = nx.shortest_path(g, 1, 3) +p1 = [p1] +p2 = list(nx.all_shortest_paths(g, 1, 3)) +p1 += p2 +pr = [sp[::-1] for sp in p1] +nx.draw(g) \ No newline at end of file