summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathann Cohen <nathann.cohen@gmail.com>2015-07-27 10:53:16 +0200
committerMichele Borassi <michele.borassi@imtlucca.it>2015-07-28 12:42:54 +0200
commit59098e600504078a8d718f93383ac7d49a354e6c (patch)
tree08e31d1380e76b223de7c8e2a727e1159e341d70
parentModified spkg-src according to Nathann's suggestions. (diff)
trac #18929: Reviewer's commit
-rw-r--r--build/pkgs/igraph/SPKG.txt8
-rw-r--r--build/pkgs/python_igraph/SPKG.txt8
-rw-r--r--src/sage/graphs/digraph.py22
-rw-r--r--src/sage/graphs/generic_graph.py7
-rw-r--r--src/sage/graphs/graph.py6
5 files changed, 21 insertions, 30 deletions
diff --git a/build/pkgs/igraph/SPKG.txt b/build/pkgs/igraph/SPKG.txt
index 8acc47e..faf25d2 100644
--- a/build/pkgs/igraph/SPKG.txt
+++ b/build/pkgs/igraph/SPKG.txt
@@ -2,9 +2,9 @@
== Description ==
-igraph is a library for creating and manipulating graphs.
+igraph is a library for creating and manipulating graphs.
It is intended to be as powerful (ie. fast) as possible to enable the
-analysis of large graphs.
+analysis of large graphs.
== License ==
@@ -20,10 +20,8 @@ http://igraph.org/c/
== Dependencies ==
-Put a bulleted list of dependencies here:
-
* python
* readline
* gcc
-== Special Update/Build Instructions == \ No newline at end of file
+== Special Update/Build Instructions ==
diff --git a/build/pkgs/python_igraph/SPKG.txt b/build/pkgs/python_igraph/SPKG.txt
index 52eef18..ef07b8b 100644
--- a/build/pkgs/python_igraph/SPKG.txt
+++ b/build/pkgs/python_igraph/SPKG.txt
@@ -2,9 +2,9 @@
== Description ==
-igraph is a library for creating and manipulating graphs.
+igraph is a library for creating and manipulating graphs.
It is intended to be as powerful (ie. fast) as possible to enable the
-analysis of large graphs.
+analysis of large graphs.
== License ==
@@ -20,10 +20,8 @@ http://igraph.org/python/
== Dependencies ==
-Put a bulleted list of dependencies here:
-
* python
* readline
* igraph
-== Special Update/Build Instructions == \ No newline at end of file
+== Special Update/Build Instructions ==
diff --git a/src/sage/graphs/digraph.py b/src/sage/graphs/digraph.py
index 30455a2..a590afa 100644
--- a/src/sage/graphs/digraph.py
+++ b/src/sage/graphs/digraph.py
@@ -404,9 +404,9 @@ class DiGraph(GenericGraph):
#. An igraph Graph::
- sage: import igraph
- sage: g = igraph.Graph([(0,1),(1,2),(0,2)], directed = True)
- sage: DiGraph(g)
+ sage: import igraph # optional - python_igraph
+ sage: g = igraph.Graph([(0,1),(1,2),(0,2)], directed = True) # optional - python_igraph
+ sage: DiGraph(g) # optional - python_igraph
Digraph on 3 vertices
TESTS::
@@ -457,10 +457,10 @@ class DiGraph(GenericGraph):
If the input is an undirected igraph graph, the output is transformed into
a directed graph::
- sage: import igraph
- sage: G = igraph.Graph([(0,1),(1,2),(0,2)], directed = False)
- sage: H = DiGraph(G)
- sage: H.edges(labels=False)
+ sage: import igraph # optional - python_igraph
+ sage: G = igraph.Graph([(0,1),(1,2),(0,2)], directed = False) # optional - python_igraph
+ sage: H = DiGraph(G) # optional - python_igraph
+ sage: H.edges(labels=False) # optional - python_igraph
[(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]
"""
_directed = True
@@ -873,11 +873,9 @@ 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':
- if data.is_directed():
- self.add_edges(data.get_edgelist())
- else:
- self.add_edges(data.get_edgelist())
- self.add_edges([(w,v) for (v,w) in data.get_edgelist()])
+ self.add_edges(data.get_edgelist())
+ if not data.is_directed():
+ self.add_edges(((w,v) for (v,w) in data.get_edgelist()))
elif format == 'int':
if weighted is None: weighted = False
self.allow_loops(True if loops else False,check=False)
diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
index cc393fe..13ce7e7 100644
--- a/src/sage/graphs/generic_graph.py
+++ b/src/sage/graphs/generic_graph.py
@@ -1329,15 +1329,12 @@ class GenericGraph(GenericGraph_pyx):
sage: H.summary()
'IGRAPH D--- 3 2 -- '
"""
-
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)]
- if self.is_directed():
- g = igraph.Graph(edgelist, directed=True)
- else:
- g = igraph.Graph(edgelist, directed=False)
+
+ g = igraph.Graph(edgelist, directed=self.is_directed())
return g
def to_dictionary(self, edge_labels=False, multiple_edges=False):
diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py
index 70de8b8..84a1151 100644
--- a/src/sage/graphs/graph.py
+++ b/src/sage/graphs/graph.py
@@ -959,9 +959,9 @@ class Graph(GenericGraph):
#. An igraph graph::
- sage: import igraph
- sage: g = igraph.Graph([(0,1),(0,2)])
- sage: Graph(g)
+ sage: import igraph # optional - python_igraph
+ sage: g = igraph.Graph([(0,1),(0,2)]) # optional - python_igraph
+ sage: Graph(g) # optional - python_igraph
Graph on 3 vertices
By default, graphs are mutable and can thus not be used as a dictionary