Ask Your Question
0

Graph plotting in SMC

asked 2014-09-28 07:41:29 +0100

Han gravatar image

updated 2014-09-28 17:53:16 +0100

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 16:17:26 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-09-29 01:25:31 +0100

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 17:27:03 +0100 )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 14:34:30 +0100 )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 07:41:29 +0100

Seen: 593 times

Last updated: Sep 29 '14