Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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_, ___]] :=
Module[{vrules},
vrules = DeleteCases[
Thread[Range[
Length[vertices]] -> (VertexLabel /.
vertices[[All, 2 ;;]])], _ -> VertexLabel];
Replace[
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]],
Characters["defabc"]];
GraphPlot[RuleListFromGraph[g], VertexLabeling -> True,
VertexCoordinateRules -> GetVertexCoordinates[g]]



On 5/3/12 4:35 AM, another.schmidt@googlemail.com 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 murray@math.umass.edu
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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.