# HG changeset patch
# User Nathann Cohen
# Date 1302788234 7200
# Node ID 0ea746afe79e1bc496f3a7a054561e98a7d5e7ce
# Parent 0fd28743cd399b25b0324ffd8a91088497a518fb
trac 11182  replace NetworkX empty dictionaries as edge labels with Sage default None (reviewer's patch)
diff r 0fd28743cd39 r 0ea746afe79e sage/graphs/digraph.py
 a/sage/graphs/digraph.py Tue Apr 12 13:13:50 2011 0700
+++ b/sage/graphs/digraph.py Thu Apr 14 15:37:14 2011 +0200
@@ 83,7 +83,7 @@
INPUT:
  ``data``  can be any of the following:
+  ``data``  can be any of the following (see the ``format`` keyword):
#. A dictionary of dictionaries
@@ 93,7 +93,7 @@
#. A Sage adjacency matrix or incidence matrix
 #. A pygraphviz agraph
+ #. A pygraphviz graph
#. A SciPy sparse matrix
@@ 133,6 +133,17 @@
 ``'weighted_adjacency_matrix'``  a square Sage
matrix M, with M[i,j] equal to the weight of the single edge {i,j}.
Given this format, weighted is ignored (assumed True).
+
+  ``NX``  data must be a NetworkX DiGraph.
+
+ .. NOTE::
+
+ As Sage's default edge labels is ``None`` while NetworkX uses
+ ``{}``, the ``{}`` labels of a NetworkX digraph are automatically
+ set to ``None`` when it is converted to a Sage graph. This
+ behaviour can be overruled by setting the keyword
+ ``convert_empty_dict_labels_to_None`` to ``False`` (it is
+ ``True`` by default).
 ``boundary``  a list of boundary vertices, if none,
digraph is considered as a 'digraph without boundary'
diff r 0fd28743cd39 r 0ea746afe79e sage/graphs/graph.py
 a/sage/graphs/graph.py Tue Apr 12 13:13:50 2011 0700
+++ b/sage/graphs/graph.py Thu Apr 14 15:37:14 2011 +0200
@@ 75,33 +75,6 @@
Graph Format

The Sage Graph Class: NetworkX plus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sage graphs are actually NetworkX graphs, wrapped in a Sage class.
In fact, any graph can produce its underlying NetworkX graph. For
example,

::

 sage: import networkx
 sage: G = graphs.PetersenGraph()
 sage: N = G.networkx_graph()
 sage: isinstance(N, networkx.graph.Graph)
 True

The NetworkX graph is essentially a dictionary of dictionaries of dictionaries::

 sage: N.adj
 {0: {1: {}, 4: {}, 5: {}}, 1: {0: {}, 2: {}, 6: {}}, 2: {1: {}, 3: {}, 7: {}}, 3: {8: {}, 2: {}, 4: {}}, 4: {0: {}, 9: {}, 3: {}}, 5: {0: {}, 8: {}, 7: {}}, 6: {8: {}, 1: {}, 9: {}}, 7: {9: {}, 2: {}, 5: {}}, 8: {3: {}, 5: {}, 6: {}}, 9: {4: {}, 6: {}, 7: {}}}

Each dictionary key is a vertex label, and each key in the
following dictionary is a neighbor of that vertex. In undirected
graphs, there is redundancy: for example, the dictionary containing
the entry ``1: {2: {}}`` implies it must contain
``{2: {1: {}}``. The innermost entry of ``{}`` is
related to edge labeling (see section :ref:`Graph:labels`).

Supported formats
~~~~~~~~~~~~~~~~~
@@ 123,6 +96,7 @@
::
+ sage: import networkx
sage: K = networkx.complete_bipartite_graph(12,7)
sage: G = Graph(K)
sage: G.degree()
@@ 460,7 +434,7 @@
INPUT:
  ``data``  can be any of the following:
+  ``data``  can be any of the following (see the ``format`` argument):
#. A dictionary of dictionaries
@@ 470,11 +444,11 @@
#. A Sage adjacency matrix or incidence matrix
 #. A pygraphviz agraph
+ #. A pygraphviz graph
#. A SciPy sparse matrix
 #. A NetworkX digraph
+ #. A NetworkX graph
 ``pos``  a positioning dictionary: for example, the
spring layout from NetworkX for the 5cycle is::
@@ 523,6 +497,17 @@
iterable container of elliptic curves, and the graph produced has
each curve as a vertex (it's Cremona label) and an edge EF
labelled p if and only if E is congruent to F mod p
+
+  ``NX``  data must be a NetworkX Graph.
+
+ .. NOTE::
+
+ As Sage's default edge labels is ``None`` while NetworkX uses
+ ``{}``, the ``{}`` labels of a NetworkX graph are automatically
+ set to ``None`` when it is converted to a Sage graph. This
+ behaviour can be overruled by setting the keyword
+ ``convert_empty_dict_labels_to_None`` to ``False`` (it is
+ ``True`` by default).
 ``boundary``  a list of boundary vertices, if
empty, graph is considered as a 'graph without boundary'