Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Evaluating a symbolic expression for a Graph

I'm able to do this:

sage: f = function('radius', nargs=1, evalf_func=Graph.radius)
sage: f(graphs.HouseGraph())
2

But not this:

sage: var('G')
sage: expr = f(G)
sage: expr.subs(G=graphs.HouseGraph())
...
TypeError: no canonical coercion from <class 'sage.graphs.graph.Graph'> to Symbolic Ring

What am I missing? Is it not possible to use symbolic expressions like this?

Evaluating a symbolic expression for a Graph

I'm able to do this:

sage: f = function('radius', nargs=1, evalf_func=Graph.radius)
sage: f(graphs.HouseGraph())
2

But not this:

sage: var('G')
sage: expr = f(G)
sage: expr.subs(G=graphs.HouseGraph())
...
TypeError: no canonical coercion from <class 'sage.graphs.graph.Graph'> to Symbolic Ring

What am I missing? Is it not possible to use symbolic expressions like this?