ShowGraph [{{e1, e2}, {e1, e3}}, {e1, e2, e3}]; // what is the problem?

does not display the specified graph in the Mathematica Graph Theory package "Combinatorica".

0
source share
4 answers

Ok, thanks everyone. Let me gather all these discussions. First of all, as Janus noted, there are two ways to draw graphs in Mathematica. The first is the Combinatorica path, which comes as a supplement. Secondly, the GraphPlot method, which is a built-in implementation of Mathematica for drawing graphs. GraphPlot uses the Spring layout to draw graphs. According to three people, we use ShowGraph [] to draw graphs in combination with combinatorics.

, , ShowGraph []. Mathematica 7 ,

ShowGraph [g] g.

, ?

[e, v, opts] , e - , , v - , options opts - "

, Combinatorica , . ... , Combinatorica g. g[[0]] Graph, g[[1]] , g[[2]] . ?

, g[[1]] g[[2]] Graph. :

e = {{1,2}, {{1,3}}}
opts = {{{0,0}}, {{-5,5}}, {{5,5}}}
g = Graph[e, opts]

1, 2 3. , ? Combinatorica VertexLabel ShowGraph []. VertexLabel- > True, , 1, 2 3. , :

ShowGraph[g, VertexLabel->{a,b,c}]

, ?:.)

. . Combinatorica .

, , . . , :

g = Random[10, 0.23]

10 , 0,23.

, ,
Combinatorica!

+1

, Mathematica : , Combinatorica GraphUtilities.

, , Combinatorica - , , , . GraphUtilities, , , Mathematica.

,

Needs["GraphUtilities`"]
GraphPlot[{e1 -> e2, e1 -> e3}, VertexLabeling -> True, DirectedEdges -> True]
+4

1 2 1 3, :

Needs["Combinatorica`"]
ShowGraph@AddEdges[EmptyGraph[3], {{1, 2}, {1, 3}}]

, " " Mathematica's Combinatorica.

+3
ShowGraph[
 Graph[
 {{{1, 2}}, {{2, 3}}, {{3, 1}}}, 
 {{{0, 0}, VertexLabel -> v1}, 
  {{2, 5}, VertexLabel -> v2}, 
  {{5, 5}, VertexLabel -> v3}}
 ]
]

, , .

The Combinatorica method creates a Graph object, it seems very cumbersome. It would be easier for me to create an intermediate function that would give a Graph object with the same GraphPlot syntax. Thus, you would not need to explicitly record the coordinates of the vertices and not use the cumbersome {{x, y}, opts} notation, which becomes {{x, y}} if you have no choice to indicate.

So, you may have a function such as:

myGraphPlot[{{e1,e2},{e1,e3}},{e1,e2,e3}]

to get the code at the top.

0
source

Source: https://habr.com/ru/post/1758315/


All Articles