#5046: converting between Graph and DiGraph naturally
--------------------------+-------------------------------------------------
Reporter: jason | Owner: rlm
Type: defect | Status: new
Priority: major | Milestone: sage-3.3
Component: graph theory | Keywords:
--------------------------+-------------------------------------------------
This should work. At the very minimum, there should be a sensible error
message:
{{{
sage: DiGraph(graphs.PathGraph(4))
---------------------------------------------------------------------------
NetworkXError Traceback (most recent call
last)
/home/grout/.sage/<ipython console> in <module>()
/home/grout/sage-3.2.3/local/lib/python2.5/site-
packages/sage/graphs/graph.pyc in __init__(self, data, pos, loops, format,
boundary, weighted, implementation, sparse, vertex_labels, **kwds)
8362 else:
8363 if implementation == 'networkx':
-> 8364 self._backend =
NetworkXGraphBackend(networkx.XDiGraph(data, selfloops=loops, **kwds))
8365 elif implementation == 'c_graph':
8366 if data is None:
/home/grout/sage-3.2.3/local/lib/python/networkx/xdigraph.py in
__init__(self, data, name, selfloops, multiedges)
118 self.multiedges=multiedges
119 if data is not None:
--> 120 convert.from_whatever(data,create_using=self)
121 self.name=name
122
/home/grout/sage-3.2.3/local/lib/python/networkx/convert.py in
from_whatever(thing, create_using)
114
115 raise networkx.NetworkXError, \
--> 116 "Input is not a known data type for conversion."
117
118 return
NetworkXError: Input is not a known data type for conversion.
sage: Graph(DiGraph({0:[1,2],1:[0,3]}))
---------------------------------------------------------------------------
NetworkXError Traceback (most recent call
last)
/home/grout/.sage/<ipython console> in <module>()
/home/grout/sage-3.2.3/local/lib/python2.5/site-
packages/sage/graphs/graph.pyc in __init__(self, data, pos, loops, format,
boundary, weighted, implementation, sparse, vertex_labels, **kwds)
7022 self.add_vertices(xrange(data))
7023 else:
-> 7024 self._backend =
NetworkXGraphBackend(networkx.XGraph(data, selfloops=loops, **kwds))
7025 elif implementation == 'c_graph':
7026 if data is None:
/home/grout/sage-3.2.3/local/lib/python/networkx/xgraph.py in
__init__(self, data, name, selfloops, multiedges)
111 self.multiedges=multiedges
112 if data is not None:
--> 113 self=convert.from_whatever(data,create_using=self)
114 self.name=name
115
/home/grout/sage-3.2.3/local/lib/python/networkx/convert.py in
from_whatever(thing, create_using)
114
115 raise networkx.NetworkXError, \
--> 116 "Input is not a known data type for conversion."
117
118 return
NetworkXError: Input is not a known data type for conversion.
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5046>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---