The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: new Graph function + combinatorica: various problems
Replies: 8   Last Post: May 5, 2012 4:12 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Murray Eisenberg

Posts: 2,105
Registered: 12/6/04
Re: new Graph function + combinatorica: various problems
Posted: May 3, 2012 10:23 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

This was discussed in MathGroup about three years ago. Here are some
functions towards a solution that were provided in responses there.

(* Convert Combinatorica type Graph object to the list of rules expected
by GraphPlot *)

RuleListFromGraph[Graph[edges_, vertices_, ___]] :=
vrules = DeleteCases[
Length[vertices]] -> (VertexLabel /.
vertices[[All, 2 ;;]])], _ -> VertexLabel];
Transpose[{Rule @@@ (edges[[All, 1]] /. vrules),
EdgeLabel /. edges[[All, 2 ;;]]}], {a_, EdgeLabel} -> a, {1}]]

(* Preserve original coordinates of vertices lost by the above *)
GetVertexCoordinates[Graph[edges_, vertices_, ___]] :=
vertices[[All, 1]]

(* Example *)
g = SetEdgeLabels[
SetVertexLabels[Wheel[4], Range[4]],
GraphPlot[RuleListFromGraph[g], VertexLabeling -> True,
VertexCoordinateRules -> GetVertexCoordinates[g]]

On 5/3/12 4:35 AM, wrote:
> nice. Can anybody tell me a convenient way to convert an explicit Combinatorica graph g to a System Graph g2 without using wrappers?
> Thanks a lot.
> Jesch

Murray Eisenberg
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.