summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Borassi <michele.borassi@imtlucca.it>2015-07-27 15:09:54 +0200
committerMichele Borassi <michele.borassi@imtlucca.it>2015-07-28 12:42:54 +0200
commit20ca006c5fa8d83ba64aa9350c47f0d0022143dd (patch)
tree62370ec7fd26010aadd191a188984c5f62fe1b42
parentSolved bug if igraph is not installed (diff)
Solved a problem with isolated vertices
-rw-r--r--src/sage/graphs/digraph.py1
-rw-r--r--src/sage/graphs/generic_graph.py5
-rw-r--r--src/sage/graphs/graph.py1
3 files changed, 4 insertions, 3 deletions
diff --git a/src/sage/graphs/digraph.py b/src/sage/graphs/digraph.py
index 94bb4f2..e3fefcc 100644
--- a/src/sage/graphs/digraph.py
+++ b/src/sage/graphs/digraph.py
@@ -876,6 +876,7 @@ class DiGraph(GenericGraph):
self.add_vertices(data.nodes())
self.add_edges((u,v,r(l)) for u,v,l in data.edges_iter(data=True))
elif format == 'igraph':
+ self.add_vertices(range(data.vcount()))
self.add_edges(data.get_edgelist())
if not data.is_directed():
self.add_edges(((w,v) for (v,w) in data.get_edgelist()))
diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
index 97f87e6..4802cae 100644
--- a/src/sage/graphs/generic_graph.py
+++ b/src/sage/graphs/generic_graph.py
@@ -1333,9 +1333,8 @@ class GenericGraph(GenericGraph_pyx):
import igraph
v_to_int = {v:i for i,v in enumerate(self.vertices())}
edgelist = [(v_to_int[v],v_to_int[w])
- for v,w in self.edges(labels=False)]
-
- return igraph.Graph(edgelist, directed=self.is_directed())
+ for v,w in self.edges(labels=False)]
+ return igraph.Graph(self.num_verts(), edgelist, directed=self.is_directed())
except ImportError:
raise ImportError("The package igraph is not available. To " +
"install it, run Sage with option -i " +
diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py
index bb11387..86c82af 100644
--- a/src/sage/graphs/graph.py
+++ b/src/sage/graphs/graph.py
@@ -1394,6 +1394,7 @@ class Graph(GenericGraph):
self.add_vertices(data.nodes())
self.add_edges((u,v,r(l)) for u,v,l in data.edges_iter(data=True))
elif format == 'igraph':
+ self.add_vertices(range(data.vcount()))
self.add_edges(data.get_edgelist())
elif format == 'rule':
f = data[1]