Ask Your Question
0

Graph plotting in SMC

asked 10 years ago

Han gravatar image

updated 10 years ago

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?

Preview: (hide)

Comments

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

dazedANDconfused gravatar imagedazedANDconfused ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 10 years ago

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()
Preview: (hide)
link

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 ( 10 years ago )

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 ( 10 years ago )

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: 10 years ago

Seen: 749 times

Last updated: Sep 29 '14