Re: new Graph function + combinatorica: various problems
- To: mathgroup at smc.vnet.net
- Subject: [mg126357] Re: new Graph function + combinatorica: various problems
- From: Jens <another.schmidt at googlemail.com>
- Date: Thu, 3 May 2012 22:22:26 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <ij2v05$7uu$1@smc.vnet.net> <201205030835.EAA29999@smc.vnet.net> <4FA29C92.1070802@math.umass.edu>
Thanks a lot. But eventually I want to export the (converted)
System`graph to a specific file format ("graph6"). The conversion to a
List of Edge Rules works fine and suffices for GraphPlot, but not for
exporting. I get the error message: "The element "AdjacencyMatrix
contains a malformed data structure and could not be exported to Graph6
format."
I guess there are some other elements in the System`graph format that
the export function needs.
On 03.05.2012 16:56, Murray Eisenberg wrote:
> 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 at 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
>>
>
- References:
- Re: new Graph function + combinatorica: various problems
- From: another.schmidt@googlemail.com
- Re: new Graph function + combinatorica: various problems