Ask Your Question
0

Graph plotting in SMC

asked 2014-09-28 00:41:29 -0500

Han gravatar image

updated 2014-09-28 10:53:16 -0500

I was trying to plot some graphs in SMC. However, even the first example given in Graph Plotting doesn't work. I only got an empty output. The following is the example i was trying.

sage: G = graphs.WheelGraph(15)

sage: G.plot()

What am I missing in my example?

P.S.: Yes. The example works in Sage worksheets, however, it doesn't work in iPython notebook. How to make it work in iPython notebook?

edit retag flag offensive close merge delete

Comments

Nothing missing; the code works in a [Sage Cell Server](https://sagecell.sagemath.org/).

dazedANDconfused gravatar imagedazedANDconfused ( 2014-09-28 09:17:26 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-28 18:25:31 -0500

calc314 gravatar image

Try the following code in ipython in SMC to load the sage commands and the networkx library. Then, you can see the graph.

from sage.all import *
import networkx as nx
G = graphs.WheelGraph(15)
H=G.networkx_graph()
nx.draw(H)
plt.savefig("simple_path.png")
plt.show()
edit flag offensive delete link more

Comments

I'm afraid the code cannot return what I expected. Yes, it returns a Wheel graph with 15 vertices. But the graph drawn there is ugly. Thank you for sharing anyway.

Han gravatar imageHan ( 2014-09-29 10:27:03 -0500 )edit

I get the same graph in iPython as in Sage. There are some formatting options for graphs that can be used in Sage. I imagine that networkx has similar options that might allow you to get the format that you want.

calc314 gravatar imagecalc314 ( 2014-10-01 07:34:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-09-28 00:41:29 -0500

Seen: 53 times

Last updated: Sep 28 '14