From: J. McKenzie Alexander on
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




From: Mark McClure on
On Sun, Nov 29, 2009 at 5:11 AM, J. McKenzie Alexander <jalex(a)lse.ac.uk> wrote:
> 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.

If you specify the graph using an adjacency matrix representation, then it
does "know" how many vertices you've got and draws isolated vertices
accordingly. In particular, your problem can be solved using
GraphPlot[{{}}]

Of course, I'm not sure how well that fits into your overall scheme.

Mark McClure

From: Murray Eisenberg on
You can finesse this by using the form

GraphPlot[m]

where m is the adjacency matrix. For example, for a 3-vertex null graph:

GraphPlot[ConstantArray[0, {3, 3}]]


J. McKenzie Alexander wrote:
> 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
>
>
>
>

--
Murray Eisenberg murray(a)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

From: J. McKenzie Alexander on
Many thanks to all those who responded. One further question: how does one assign labels to edges if calling GraphPlot on an adjacency matrix? I tried the following (which struck me as a natural guess at what the syntax might be), but it failed:

GraphPlot[
{ {0, {1, 0.5}, {1, 0.5}},
{ {1, 0.5}, 0, {1, 0.5}},
{ {1, 0.5}, {1, 0.5}, 0}}, MultiedgeStyle -> True]

>From what I see in the documentation, there doesn't seem to be a way to include edge labels using the adjacency matrix representation, unless I explicitly override EdgeRenderingFunction. Is that right?

Cheers,

Jason


On 30 Nov 2009, at 11:11, Murray Eisenberg wrote:

> You can finesse this by using the form
>
> GraphPlot[m]
>
> where m is the adjacency matrix. For example, for a 3-vertex null graph:
>
> GraphPlot[ConstantArray[0, {3, 3}]]
>
>
> J. McKenzie Alexander wrote:
>> 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
>>
>>
>>
>>
>
> --
> Murray Eisenberg murray(a)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
>

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




Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm