Re: Changing Graph style
- To: mathgroup at smc.vnet.net
- Subject: [mg114496] Re: Changing Graph style
- From: Yaroslav Bulatov <yaroslavvb at gmail.com>
- Date: Sun, 5 Dec 2010 21:56:33 -0500 (EST)
- References: <idag78$jmk$1@smc.vnet.net> <idd7ks$n8c$1@smc.vnet.net>
On Dec 4, 3:11 am, dr DanW <dmaxwar... at gmail.com> wrote:
> Particularly disappointing is that Graph can't deal with mixed graphs
> (directed and undirected edges in the same graph) or multiple edges
> between a single pair of nodes. This limits Graph from working with
> many legitimate and interesting graph problems. They sure look
> pretty, though.
>
> Daniel
To answer my own question about mixing 2 Graph types, I found the
following approach works out well to avoid ambiguities while giving
full access to both old and new functionality.
1. Use a prefix on graph variables to indicate whether it's
Combinatorica or System graph
2. Use full context path on conflicting functions
3. Use GraphUtilities`ToCombinatoricaGraph and
Combinatorica`ToOrderedPairs to convert between representations
So for instance, you could get shortest paths spanning tree as follows
Needs["Combinatorica`"];
Needs["GraphUtilities`"];
sysGraph = System`GridGraph[{2, 3}];
combGraph = GraphUtilities`ToCombinatoricaGraph[sysGraph];
combTree = Combinatorica`ShortestPathSpanningTree[combGraph, 2];
sysTree =
System`Graph[
DirectedEdge @@@
ToOrderedPairs[ShortestPathSpanningTree[combTree, 2]]]
----
http://stackoverflow.com/users/419116/yaroslav-bulatov