MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: FromAdjacencyMatrix /

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104346] Re: [mg104220] Re: [mg104192] FromAdjacencyMatrix /
  • From: Thomas Dowling <thomasgdowling at gmail.com>
  • Date: Wed, 28 Oct 2009 04:09:09 -0500 (EST)
  • References: <200910230233.WAA27768@smc.vnet.net>

Hello, Syd and Andrew,

Just to confirm, I have evaluated your notebook (confirmation for andrew.nb)
on my Mac
(non-intel PowerBook G4 running Mathematica 7.0, with Mac OS X ver 10.5.7)
and I have (still) not been able to reproduce the problem on this system.

The arrows run from 3 -> 1 on both G2 graphs afer evaluation on my Mac, but
point from 1 -> 3 on
the downloaded notebook.

Also, the final command

Edges[g] == Edges[g2]

evaluates to True (It has evaluated to False in the downloaded notebook).

This must be a bug, which is a bit worrying.  We are soon to update to M.
7.1 (in the next few days), and
it will be interesting to see what happens.

Tom Dowling

"7.0 for Mac OS X PowerPC (32-bit) "

Tom Dowling

On Sat, Oct 24, 2009 at 6:38 AM, Thomas Dowling <thomasgdowling at gmail.com>wrote:

> Hello,
>
> I have not been able to reproduce your problem on a Mac (Non-Intel) running
> Mathematica v 7.0.0.  All the code you posted works fine, but there is no
> edge-order reversal,
> and the final graph is the same as the one you started out with.  Perhaps I
> am missing something?
>
>
> Edges[g2] == Edges[g]
>
> Out[53] = True
>
> (Loading Graphics Utilities Package)
>
> EdgeList[g2] == EdgeList[g]
>
> Out[54]= True
>
> VertexList[g2] == VertexList[g]
>
> Out[56]= True
>
> EdgeList[ToCombinatoricaGraph[mg]] == EdgeList[g]
>
> Out[57]= True.
>
> mgalt = Normal@AdjacencyMatrix[g]
>
> mgalt == mg
>
> Out[63] = True
>
> Is this a particular problem with your system,  or is it peculiar to
> Mathematica 7.0.1?
>
> Tom Dowling.
>
>
>
> On Fri, Oct 23, 2009 at 3:33 AM, Andrew <dr.a.graham at googlemail.com>
> wrote:
>
> > Hello group,
> >
> > This question seems to have been touched on in the past but I'm not
> > sure if it has ever been definitively answered. I would be grateful
> > for some advice!
> >
> > I have some data that I would like to explore. It concerns a set of
> > directed graphs, without edge weights. The data comes to me as the
> > corresponding asymmetric adjacency matrices.
> >
> > I can visualise the graphs directly using the native function
> > GraphPlot.
> > However, I would prefer to visualise them using ShowGraph from the
> > Combinatorica package - but this requires that the adjacency matrix is
> > converted to the Combinatorica graph format first.
> >
> > The trouble is that (for directed graphs at least),
> > FromAdjacencyMatrix appears to be broken.
> >
> > Example:
> > g = Cycle[3, Type -> Directed] (*construct a simple directed graph in
> > Combinatorica graph format*)
> >
> > Edges[g] (*List of edges*)
> >
> > Vertices[g] (*List of vertices*)
> >
> > GraphOptions[g] (*Shows the graph options*)
> >
> > ShowGraph[g, VertexNumber -> True] /.
> >  x : Arrow[__] -> {Arrowheads[{{Automatic, 0.6}}], x} (*Visualises the
> > graph with ShowGraph, using a workaround to place the arrowheads mid-
> > edge, as suggested Apr 2 2008 by dh*)
> > GraphPlot[g, VertexLabeling -> True, DirectedEdges -> True]
> > (*Visualises the graph with GraphPlot - the same outcome*)
> >
> > mg = ToAdjacencyMatrix[g, Type -> Directed] (*Convert to adjacency
> > matrix*)
> >
> > mg // TableForm (*Inspect - seems appropriate*)
> >
> > mg // MatrixForm (*Ditto*)
> >
> > GraphPlot[mg, VertexLabeling -> True, DirectedEdges -> True] (*Cannot
> > plot directly with ShowGraph, but with GraphPlot the graph is still
> > preserved at this stage*)
> >
> > g2 = FromAdjacencyMatrix[mg, Type -> Directed] (*Convert back to a
> > graph*)
> >
> > Edges[g2] (*Oh dear. The direction of edge #3 has been reversed*)
> >
> > Vertices[g2] (*Vertices are preserved*)
> >
> > GraphOptions[g2] (*Graph options are preserved*)
> >
> > ShowGraph[g2, VertexNumber -> True] /.
> >  x : Arrow[__] -> {Arrowheads[{{Automatic, 0.6}}], x}
> > GraphPlot[g2, VertexLabeling -> True, DirectedEdges -> True] (*And
> > visualising the graph with both ShowGraph & GraphPlot it is no longer
> > the same as the graph we started out with*)
> >
> > The problem seems to be with FromAdjacencyMatrix
> > FromAdjacencyLists shows the same problem
> >
> > Is there something wrong with the code above, or are these functions
> > truly broken? If they are broken, can anyone help with writing a
> > function that will correctly turn a directed adjacency matrix into
> > Combinatorica lists of edges & vertices?
> >
> > Finally, if these functions are broken, can they be fixed? I have
> > otherwise found Combinatorica very easy to work with & would prefer to
> > stick with it rather than native functions if possible. The
> > Combinatorica book has recently been republished in paperback & I have
> > found it very helpful.
> >
> > Many thanks
> >
> > Andrew Graham
> > Dept of Neurology
> > Addenbrooke's Hospital
> >
> >
>
>
>



  • Prev by Date: Help Developing a Demonstration Project
  • Next by Date: Re: Working with Lists
  • Previous by thread: Re: FromAdjacencyMatrix / FromAdjacencyLists - broken?
  • Next by thread: Re: FromAdjacencyMatrix / FromAdjacencyLists - broken? Workaround?