I'm trying to create the following graph in Mathematica
Where do I start? I'm specifically trying to make a graph so that I can use it in TravelingSalesman[g]
, for g
a graph. This is what I have:
g := Graph[{1 \[UndirectedEdge] 2, 1 \[UndirectedEdge] 3,
1 \[UndirectedEdge] 5, 1 \[UndirectedEdge] 4,
4 \[UndirectedEdge] 5, 4 \[UndirectedEdge] 3,
4 \[UndirectedEdge] 2, 3 \[UndirectedEdge] 5,
3 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 5},
EdgeWeight -> {4, 5, 6, 3, 4, 5, 6, 7, 2, 7}]
Calling
TravelingSalesman[g]
I get the following result:
Table::iterb: Iterator {Combinatorica`Private`i$828,V[Graph[{1\[UndirectedEdge]2,1\[UndirectedEdge]3,1\[UndirectedEdge]5,1\[UndirectedEdge]4,4\[UndirectedEdge]5,4\[UndirectedEdge]3,4\[UndirectedEdge]2,3\[UndirectedEdge]5,3\[UndirectedEdge]2,2\[UndirectedEdge]5},EdgeWeight->{4,5,6,3,4,5,6,7,2,7}]]} does not have appropriate bounds. >>
Join::heads: Heads Combinatorica`Private`Double and Table at positions 1 and 2 are expected to be the same. >>
Join::heads: Heads Combinatorica`Private`Double and Table at positions 1 and 2 are expected to be the same. >>
Join::heads: Heads Combinatorica`Private`Double and List at positions 1 and 2 are expected to be the same. >>
General::stop: Further output of Join::heads will be suppressed during this calculation. >>
Table::iterb: Iterator {V[Graph[{1\[UndirectedEdge]2,1\[UndirectedEdge]3,1\[UndirectedEdge]5,1\[UndirectedEdge]4,4\[UndirectedEdge]5,4\[UndirectedEdge]3,4\[UndirectedEdge]2,3\[UndirectedEdge]5,3\[UndirectedEdge]2,2\[UndirectedEdge]5},EdgeWeight->{4,5,6,3,4,5,6,7,2,7}]]} does not have appropriate bounds. >>
Table::iterb: Iterator {V[Graph[{1\[UndirectedEdge]2,1\[UndirectedEdge]3,1\[UndirectedEdge]5,1\[UndirectedEdge]4,4\[UndirectedEdge]5,4\[UndirectedEdge]3,4\[UndirectedEdge]2,3\[UndirectedEdge]5,3\[UndirectedEdge]2,2\[UndirectedEdge]5},EdgeWeight->{4,5,6,3,4,5,6,7,2,7}]]} does not have appropriate bounds. >>
General::stop: Further output of Table::iterb will be suppressed during this calculation. >>
Range::range: Range specification in Range[V[Graph[{1\[UndirectedEdge]2,1\[UndirectedEdge]3,1\[UndirectedEdge]5,1\[UndirectedEdge]4,4\[UndirectedEdge]5,4\[UndirectedEdge]3,4\[UndirectedEdge]2,3\[UndirectedEdge]5,3\[UndirectedEdge]2,2\[UndirectedEdge]5},EdgeWeight->{4,5,6,3,4,5,6,7,2,7}]]] does not have appropriate bounds. >>
TravelingSalesman::ham: The graph must contain a Hamiltonian cycle for a traveling salesman tour to be found. >>
Needs["Combinatorica`"]
." But this is now deprecated in favour of the built-in graph functions. $\endgroup$