Best,
Diego
Some toy examples that work in Sage 4.2 but not in Sage 4.4:
----------------------------------------------------------------------
| Sage Version 4.2, Release Date: 2009-10-24 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: G=DiGraph(weighted=True)
sage: G.add_edge(0,1,5)
sage: G.add_edge(1,2,2)
sage: G.vertices()
[0, 1, 2]
sage: G.shortest_path_length(0,2,by_weight=True)
7
sage: G.shortest_path_length(G.vertices()[0],G.vertices()
[2],by_weight=True)
7
sage:
sage: G=DiGraph(weighted=True)
sage: G.add_edge((0,0),(1,0),5)
sage: G.add_edge((1,0),(2,0),2)
sage: G.vertices()
[(0, 0), (1, 0), (2, 0)]
sage: G.shortest_path_length((0, 0),(2, 0),by_weight=True)
7
sage: G.shortest_path_length(G.vertices()[0],G.vertices()
[2],by_weight=True)
7
But in Sage 4.4: (it does not even work when I use G.vertices()[0] and
G.vertices()[2]
----------------------------------------------------------------------
| Sage Version 4.4, Release Date: 2010-04-24 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: G=DiGraph(weighted=True)
sage: G.add_edge(0,1,5)
sage: G.add_edge(1,2,2)
sage: G.vertices()
[0, 1, 2]
sage: G.shortest_path_length(0,2,by_weight=True)
7
sage: G.shortest_path_length(G.vertices()[0],G.vertices()
[2],by_weight=True)
7
sage:
sage: G=DiGraph(weighted=True)
sage: G.add_edge((0,0),(1,0),5)
sage: G.add_edge((1,0),(2,0),2)
sage: G.vertices()
[(0, 0), (1, 0), (2, 0)]
sage: G.shortest_path_length((0, 0),(2, 0),by_weight=True)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call
last)
/user/diego/<ipython console> in<module>()
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/
generic_graph.pyc in shortest_path_length(self, u, v, by_weight,
bidirectional, weight_sum)
7699 if weight_sum is None:
7700 weight_sum = by_weight
-> 7701 path = self.shortest_path(u, v, by_weight,
bidirectional)
7702 length = len(path) - 1
7703 if length == -1:
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/
generic_graph.pyc in shortest_path(self, u, v, by_weight,
bidirectional)
7631 if bidirectional:
7632 try:
-> 7633 L =
self._backend.bidirectional_dijkstra(u,v)
7634 except AttributeError:
7635 try:
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/base/
c_graph.so in
sage.graphs.base.c_graph.CGraphBackend.bidirectional_dijkstra (sage/
graphs/base/c_graph.c:12323)()
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/base/
sparse_graph.so in
sage.graphs.base.sparse_graph.SparseGraphBackend.get_edge_label (sage/
graphs/base/sparse_graph.c:15511)()
RuntimeError: 0 not a vertex of the graph.
sage: G.shortest_path_length(G.vertices()[0],G.vertices()
[2],by_weight=True)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call
last)
/user/diego/<ipython console> in<module>()
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/
generic_graph.pyc in shortest_path_length(self, u, v, by_weight,
bidirectional, weight_sum)
7699 if weight_sum is None:
7700 weight_sum = by_weight
-> 7701 path = self.shortest_path(u, v, by_weight,
bidirectional)
7702 length = len(path) - 1
7703 if length == -1:
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/
generic_graph.pyc in shortest_path(self, u, v, by_weight,
bidirectional)
7631 if bidirectional:
7632 try:
-> 7633 L =
self._backend.bidirectional_dijkstra(u,v)
7634 except AttributeError:
7635 try:
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/base/
c_graph.so in
sage.graphs.base.c_graph.CGraphBackend.bidirectional_dijkstra (sage/
graphs/base/c_graph.c:12323)()
/usr/local/sage-4.4/local/lib/python2.6/site-packages/sage/graphs/base/
sparse_graph.so in
sage.graphs.base.sparse_graph.SparseGraphBackend.get_edge_label (sage/
graphs/base/sparse_graph.c:15511)()
RuntimeError: 0 not a vertex of the graph.
sage: