This is also just a note.
I want to specifically draw attention to a possible bug in ToCombinatoricaGraph
and a possible workaround. It may have no relevance to the original question.
Also, I am using Mma 7, so things may be fixed in v8.
If I define a graph as follows
Needs["Combinatorica`"]
Needs["GraphUtilities`"]
gr1 = {2 -> 4, 4 -> 3, 3 -> 1}
GraphPlot of gr1

Compare the following:
EdgeList@gr1
EdgeList@ToCombinatoricaGraph@gr1
Edges@ToCombinatoricaGraph@gr1
Output
{{2, 4}, {4, 3}, {3, 1}}
{{1, 2}, {2, 3}, {3, 4}}
{{1, 2}, {2, 3}, {3, 4}}
The workaround I use is to ignore, as far as is possible, ToCombinatoricaGraph
and instead convert to a Combinatorica graph using FromOrderedPairs
.
For example
Edges@FromOrderedPairs@EdgeList@gr1
EdgeList@FromOrderedPairs@EdgeList@gr1
Output
{{2, 4}, {4, 3}, {3, 1}}
{{2, 4}, {3, 1}, {4, 3}}
Another example, Degrees
Compare
Degrees@MakeSimple@ToCombinatoricaGraph[gr1]
VertexList@MakeSimple@ToCombinatoricaGraph[gr1]
Output
{1, 2, 2, 1}
{1, 2, 3, 4}
with
Degrees@MakeSimple@FromOrderedPairs@EdgeList@gr1
VertexList@MakeSimple@FromOrderedPairs@EdgeList@gr1
{1, 1, 2, 2}
{1, 2, 3, 4}
I'll also include an example with Prufer codes, as here I was badly 'caught out' (I did not know about SO then)
LabeledTreeToCode@MakeSimple@ToCombinatoricaGraph@gr1
LabeledTreeToCode@MakeSimple@FromOrderedPairs@EdgeList@gr1
Output
{2, 3}
{3, 4}
(Only the second answer is correct)
I have reported this to Wolfram. Seemingly, it is connected to reordering of vertices on graph creation by ToCombinatoricaGraph
. Here is part of the reply (2009)
The reason that Edges and EdgeList
don't function on ToCombinatoricaGraph
objects because the Combinatorica package was developed prior to these
functions, and the structure hasn't yet been adapted to operate
with these
functions.
Our development team is currently working to update the Combinatorica
package so that these functions will be compatible. If you happen to
run
across any other issues, or have any questions come up, please do let
me
know.
In my view, ToCombinatoricaGraph
needs to be used with care (and avoided whenever possible). However, there are probably many cases (including the uses given in other answers to the original question) where it makes no difference.
Personally, I would not like to see the Combinatorica package go. It contains many useful functions (if very badly documented).