doesn’t show specified graph in Mathematica Graph Theory package ‘Combinatorica’.
doesn’t show specified graph in Mathematica Graph Theory package ‘Combinatorica’.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ok, thanks all. Let me pack up all these discussions. First of all as Janus mentioned, there are two ways to draw graphs in Mathematica. Firstly, Combinatorica way, which comes as an add in. Secondly, GraphPlot way which is a native Mathematica implementation to draw graphs. GraphPlot employs Spring layout to draw graphs. As dreeves said we use ShowGraph[] to draw graphs in Combinatorica way.
To understand why the mentioned code doesn’t work we have to understand ShowGraph[] command very well. Mathematica 7 defines,
Now, what is graph?
The problem is Combinatorica doesn’t seem to work exactly the above defined way. Let’s examine… suppose you’ve created a Combinatorica graph named g. Now
g[[0]]would printGraph,g[[1]]would print list of edges,g[[2]]would print opts. Where is list of vertices??As you can see above, you can manually create
g[[1]], andg[[2]]and feed it to Graph. Let’s create it:This will create a graph with vertices 1, 2 and 3. Now, how can you label them? In Combinatorica, you do this using VertexLabel option of ShowGraph[]. If you use VertexLabel->True it will only show default labels, that is 1, 2 and 3 here. To use your own labels do the following:
Interesting, right? :).
Now to the exact answer of my question. The problem of the mentioned code is due to the use of literal values instead of integers. Combinatorica only excepts integer values as edge or vertex list.
Remember, although it is possible it is only useful to create small graphs. For larger graphs you should use default graph generators to create your graph. Like, for a random graph use:
Will create a graph with 10 vertices, with edge probability of 0.23.
Waka, waka,
this time for Combinatorica!