MathGroup Archive 2009

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

Search the Archive

Using GraphPlot to draw an empty graph

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105358] Using GraphPlot to draw an empty graph
  • From: "J. McKenzie Alexander" <jalex at lse.ac.uk>
  • Date: Sun, 29 Nov 2009 05:11:14 -0500 (EST)

Hello,

Is there a way of making GraphPlot draw an empty graph? I realise that 
this is an ill-defined question if one uses the default options for 
GraphPlot because there is no way for GraphPlot to know how many 
vertices it should draw. However, it turns out that even if one set a 
custom value for VertexCoordinateRule the vertices aren't drawn:

GraphPlot[{},
VertexRenderingFunction -> ({Black, Disk[#1, 0.05] } &),
VertexCoordinateRules ->
Table[{Cos[theta], Sin[theta]}, {theta, 0, 2 Pi, 2 Pi/11}]
]

I know that I could easily draw this "by hand" using Graphics, but I 
have good reason for wanting to use GraphPlot. (I wrap the GraphPlot in 
Dynamic where the list of edges is specified by a variable. Most of the 
time the variable contains a connected graph, but sometimes it is 
empty.)

As an aside, the following "works" as a way of giving the impression of 
an empty graph, but it does so by forcing each node to have a self-loop 
(and then suppressing those edges from being drawn). It would be nice to 
have a cleaner solution.

GraphPlot[Table[i -> i, {i, 0, 11}],
VertexRenderingFunction -> ({Black, Disk[#1, 0.05]} &),
SelfLoopStyle -> None,
VertexCoordinateRules ->
Table[N[{Cos[theta], Sin[theta]}], {theta, 0, 2 Pi, 2 Pi/11}]
]

Cheers,

Jason

--
Dr J. McKenzie Alexander
Department of Philosophy, Logic and Scientific Method
London School of Economics and Political Science
Houghton Street, London WC2A 2AE





  • Prev by Date: Re: distorting an image
  • Next by Date: Re: Replacement rules that contain function arguments
  • Previous by thread: Mathematica 7 crash on confusing setting of Manipulate Controls
  • Next by thread: Re: Using GraphPlot to draw an empty graph