You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_sp_methods.py 382 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Test networkx shortest paths methods.
  5. Created on Tue Oct 9 14:49:09 2018
  6. @author: ljia
  7. """
  8. import networkx as nx
  9. g = nx.Graph()
  10. g.add_edge(1, 2)
  11. g.add_edge(3, 2)
  12. g.add_edge(1, 4)
  13. g.add_edge(3, 4)
  14. p1 = nx.shortest_path(g, 1, 3)
  15. p1 = [p1]
  16. p2 = list(nx.all_shortest_paths(g, 1, 3))
  17. p1 += p2
  18. pr = [sp[::-1] for sp in p1]
  19. nx.draw(g)

A Python package for graph kernels, graph edit distances and graph pre-image problem.