MathGroup Archive 2005

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

Search the Archive

Re: Axes in ShowGraph

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54305] Re: [mg54259] Axes in ShowGraph
  • From: DrBob <drbob at bigfoot.com>
  • Date: Wed, 16 Feb 2005 14:36:42 -0500 (EST)
  • References: <200502150250.VAA27333@smc.vnet.net> <opsl80prh3iz9bcq@monster.ma.dl.cox.net> <001401c51385$62d37310$0200a8c0@NEWSONY>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

>> If you plot this

Plot what?

You could have posted the graph's InputForm, after all.

Still, here's an attempt to do without it:

Needs["DiscreteMath`Combinatorica`"]
Needs["Graphics`Colors`"]
{v, m} = {40, 66};
degrees = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4,
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4};
edges = {{2, 16}, {15, 1}, {16, 15}, {3, 20}, {17, 2}, {18, 17}, {19, 18}, {
     20, 19}, {4, 27}, {21, 3}, {22, 21}, {23, 22}, {24, 23}, {25, 24}, {26,
     25}, {27, 26}, {5, 32}, {
     28, 4}, {29, 28}, {30, 29}, {31, 30}, {32, 31}, {6, 33}, {
       33, 5}, {7, 20}, {21, 6}, {20, 21}, {8, 7}, {9, 35}, {19, 8}, {
     22, 19}, {33, 22}, {34, 33}, {35, 34}, {10, 18}, {36, 9}, {
     37, 36}, {30, 37}, {
     25, 30}, {
       38, 25}, {15, 38}, {18, 15}, {11, 16}, {17, 10}, {16, 17}, {12, 34}, \
{38, 11}, {24, 38}, {31, 24}, {39, 31}, {34, 39}, {13, 26}, {35, 12}, {40,
     35}, {37, 40}, {29, 37}, {26, 29}, {14, 36}, {27, 13}, {28,
     27}, {36, 28}, {1, 23}, {40, 14}, {39, 40}, {32, 39}, {23, 32}};
vertices = {{4.02, 11.02}, {3.71, 5.73}, {6.86, 13.27}, {-2.38,
     8.83}, {1.69, 11.97}, {1.63, 14.08}, {7.4, 12.05}, {
         7.54, 11.46}, {-3.85, 13.21}, {5.64,
         6.52}, {2.66, 7.35}, {-0.42, 13.44}, {-0.79, 8.44}, {-1.83, 12.39}, {
       3.831, 7.7952}, {
         3.7865, 7.0362}, {4.2068, 6.9192}, {4.404, 7.3913}, {6.1905, \
11.6673}, {6.4848, 12.372}, {5.6225, 12.6754}, {4.1706, 11.9777}, {2.7813,
         11.3101}, {1.0725, 10.489}, {0.4406, 10.1853}, {-0.7015,
       9.6366}, {-1.0597, 9.4644}, {-1.1438,
       9.7837}, {-0.6631, 10.1546}, {-0.1153,
        10.5772}, {0.707, 11.2116}, {1.2879,
       11.6598}, {1.6789, 12.3605}, {-0.0049,
        12.6192}, {-0.4754, 12.6915}, {-1.6347, 11.6483}, {-0.6062, 10.9233}, {
       1.6612, 9.3248}, {0.3718, 11.8744}, {-0.5204, 12.0833}};

g = FromUnorderedPairs@edges
Sort /@ edges == Edges@g
Degrees@g == degrees
Through[{V, M}@g] == {v, m}

"\[SkeletonIndicator]Graph:<"66", "40", ""Undirec\
ted"">\[SkeletonIndicator]"
True
True
True

But the vertices aren't right:

Vertices@g

{{0.987688,0.156434},{0.951057,0.309017},{
   0.891007,0.45399},{0.809017,0.587785},{0.707107,0.707107},{
     0.587785,0.809017},{0.45399,0.891007},{0.309017,0.951057},{
   0.156434,0.987688},{
     0,1.},{-0.156434,0.987688},{-0.309017,0.951057},{-0.45399,0.891007},{-0.\
587785,0.809017},{-0.707107,0.707107},{-0.809017,0.587785},{-0.891007,0.45399}\
,{-0.951057,0.309017},{-0.987688,
     0.156434},{-1.,0},{-0.987688,-0.156434},{-0.951057,-0.309017},{-0.891007,-\
0.45399},{-0.809017,-0.587785},{-0.707107,-0.707107},{-0.587785,-0.809017},{-\
0.45399,-0.891007},{-0.309017,-0.951057},{-0.156434,-0.987688},{0,-1.},{0.\
156434,-0.987688},{0.309017,-0.951057},{0.45399,-0.891007},{0.587785,-0.\
809017},{0.707107,-0.707107},{0.809017,-0.587785},{0.891007,-0.45399},{0.\
951057,-0.309017},{0.987688,-0.156434},{1.,0}}

So here's another try:

g = FromUnorderedPairs@edges;
g[[2]] = List /@ vertices;
Sort /@ edges == Edges@g
Degrees@g == degrees
Through[{V, M}@g] == {v, m}
Vertices@g == vertices

True
True
True
True

This test still fails:

edges==Edges@g
False

but it's an Undirected graph, so I'm satisfied (I guess), with the test Sort /@ edges == Edges@g.

Finally, I can plot the graph with some HOPE that I'm seeing the same thing as you:

sg=ShowGraph[g,
     ImageSize -> 600,
     Background -> Linen,
     VertexColor -> Cyan,
     VertexStyle -> Disk[0.035],
     VertexNumber -> True,
     VertexNumberPosition -> Center,
     TextStyle -> {FontSize -> 13, FontWeight -> Bold},
     Axes -> True,
     PlotRange -> All];

As you say, the scale seems to bear no relationship to the vertex values.

Comparison with this plot:

ListPlot[vertices, ImageSize -> 500, Frame -> True]

suggests it's just a scaling/location issue, however.

Through[{Max, Min}@#] & /@ Transpose@Vertices@g
s1 = Subtract @@@ %
Divide @@ s1

{{7.54,-3.85},{14.08,5.73}}
{11.39,8.35}
1.36407

Through[{Max, Min}@#] & /@ Transpose@Cases[sg, Point[x_] -> x, Infinity]
s2 = Subtract @@@ %
Divide @@ s2

{{0.635248,0.},{1.,0.5343}}
{0.635248,0.4657}
1.36407

s1/s2

{17.93,17.93}

Scaling and translation were applied to (1) maintain aspect ratios, (2) make the minimum x value 0, (3) make the maximum y value 1, and (4) put all x and y values in Interval[{0,1}].

I don't think those rules completely determine the transformation, but that seems to be the general idea.

Anyway, leave out Axes->True, and you'll never notice. The numerical values don't matter anyway, do they?

Bobby

On Tue, 15 Feb 2005 09:40:05 -0800, Steve Gray <stevebg at adelphia.net> wrote:

> Bobby,
>
>     Here, I think, is all the info you need. If you plot this you will see a
> graph which is really a self-crossing polygon with 14 vertices (degree 2
> nodes) and 26 edge intersections (degree 4 n odes). The simplest eulerian
> cycle in this case is just a complete circuit from one vertex to the next,
> through the intervening intersections, back to the first vertex. I need the
> eulerian cycle not for this graph but for a version of it with certain
> vertices and edges removed. This 14-gon is just an example, but unless it
> works, I can't proceed with the real problem(s).
>
>     Thanks very much for your attention.
>
> Steve
>
> In[183]:=
> comgraph
> V[comgraph]
> M[comgraph]
> ver = Vertices[comgraph]
> edg = Edges[comgraph]
> Degrees[comgraph]
> Out[183]=
> \[SkeletonIndicator]Graph:<\[InvisibleSpace]66\[InvisibleSpace], \
> \[InvisibleSpace]40\[InvisibleSpace], \[InvisibleSpace]Undirected\
> \[InvisibleSpace]>\[SkeletonIndicator]
> Out[184]=
> 40
> Out[185]=
> 66
> Out[186]=
> {{4.02, 11.02}, {3.71, 5.73}, {6.86, 13.27}, {-2.38, 8.83}, {1.69,
> 11.97}, {1.63, 14.08}, {7.4, 12.05}, {7.54, 11.46}, {-3.85, 13.21}, {5.64,
> 6.52}, {2.66, 7.35}, {-0.42, 13.44}, {-0.79, 8.44}, {-1.83,
> 12.39}, {3.831, 7.7952}, {3.7865, 7.0362}, {4.2068, 6.9192}, {4.404,
> 7.3913}, {6.1905, 11.6673}, {6.4848, 12.372}, {5.6225, 12.6754}, {4.1706,
> 11.9777}, {2.7813, 11.3101}, {1.0725, 10.489}, {0.4406,
> 10.1853}, {-0.7015, 9.6366}, {-1.0597, 9.4644}, {-1.1438,
> 9.7837}, {-0.6631, 10.1546}, {-0.1153, 10.5772}, {0.707,
> 11.2116}, {1.2879, 11.6598}, {1.6789, 12.3605}, {-0.0049,
> 12.6192}, {-0.4754, 12.6915}, {-1.6347, 11.6483}, {-0.6062,
> 10.9233}, {1.6612, 9.3248}, {0.3718, 11.8744}, {-0.5204, 12.0833}}
> Out[187]=
> {{2, 16}, {15, 1}, {16, 15}, {3, 20}, {17, 2}, {18, 17}, {19, 18}, {20,
> 19}, {4, 27}, {21, 3}, {22, 21}, {23, 22}, {24, 23}, {25, 24}, {26,
> 25}, {27, 26}, {5, 32}, {28, 4}, {29, 28}, {30, 29}, {31, 30}, {32,
> 31}, {6, 33}, {33, 5}, {7, 20}, {21, 6}, {20, 21}, {8, 7}, {9, 35}, {19,
> 8}, {22, 19}, {33, 22}, {34, 33}, {35, 34}, {10, 18}, {36, 9}, {37,
> 36}, {30, 37}, {25, 30}, {38, 25}, {15, 38}, {18, 15}, {11, 16}, {17,
> 10}, {16, 17}, {12, 34}, {38, 11}, {24, 38}, {31, 24}, {39, 31}, {34,
> 39}, {13, 26}, {35, 12}, {40, 35}, {37, 40}, {29, 37}, {26, 29}, {14,
> 36}, {27, 13}, {28, 27}, {36, 28}, {1, 23}, {40, 14}, {39, 40}, {32,
> 39}, {23, 32}}
> Out[188]=
> {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> \
> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}
>
> ----- Original Message -----
>
> From: "DrBob" <drbob at bigfoot.com>
To: mathgroup at smc.vnet.net
> To: "Steve Gray" <stevebg at adelphia.net>; <mathgroup at smc.vnet.net>
> Sent: Tuesday, February 15, 2005 9:11 AM
> Subject: [mg54305] Re: [mg54259] Axes in ShowGraph
>
>
>> If we had a value for "comgraph", we might see what you're talking about.
>>
>> Bobby
>>
>> On Mon, 14 Feb 2005 21:50:55 -0500 (EST), Steve Gray
> <stevebg at adelphia.net> wrote:
>>
>> > I have a graph with 40 vertices, displayed with this function:
>> >
>> > ShowGraph [ comgraph,
>> >       ImageSize -> 600,
>> >       Background -> RGBColor[.9, 1., .9],
>> >       VertexColor -> RGBColor[.5, .9, .9],
>> >       VertexStyle -> Disk[0.03],
>> >       VertexNumber -> True,
>> >       VertexNumberPosition -> Center,
>> >       TextStyle -> {FontSize -> 13, FontWeight -> Bold},
>> >       Axes -> True,
>> >       PlotRange -> All
>> >           ];
>> >
>> > Everything looks correct except the values displayed on the axes bear no
> relation to the
>> > values of the vertices given by Vertices[comgraph].
> (PlotRange->Automatic does the same thing.)
>> > The vertices have the values shown below, while the displayed axes run
> from about 0 to 0.64 on
>> > X and .53 to 1.0 on Y. I need the actual vertex coordinates displayed as
> they are given here:
>> >
>> > In[50]:=
>> > Vertices[comgraph]
>> >
>> > Out[50]=
>> > {{4.02,11.02},{3.71,5.73},{6.86,13.27},{-2.38,8.83},{1.69,11.97},{1.63,
>> >     14.08},{7.4,12.05},{7.54,11.46},{-3.85,13.21},{5.64,6.52},{2.66,
>> >
> 7.35},{-0.42,13.44},{-0.79,8.44},{-1.83,12.39},{3.831,7.7952},{3.7865,
>> >     7.0362},{4.2068,6.9192},{4.404,7.3913},{6.1905,11.6673},{6.4848,
>> >     12.372},{5.6225,12.6754},{4.1706,11.9777},{2.7813,11.3101},{1.0725,
>> >     10.489},{0.4406,10.1853},{-0.7015,9.6366},{-1.0597,9.4644},{-1.1438,
>> >     9.7837},{-0.6631,10.1546},{-0.1153,10.5772},{0.707,11.2116},{1.2879,
>> >
> 11.6598},{1.6789,12.3605},{-0.0049,12.6192},{-0.4754,12.6915},{-1.6347,
>> >
> 11.6483},{-0.6062,10.9233},{1.6612,9.3248},{0.3718,11.8744},{-0.5204,
>> >     12.0833}}
>> >
>> > Users of the Graph functions are probably in the minority, but can
> anyone explain this?
>> >
>> > Steve Gray
>> >
>> >
>> >
>> >
>>
>>
>>
>> --
>> DrBob at bigfoot.com
>> www.eclecticdreams.net
>>
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: Re: Using Select with arrays? (Relative newbie)
  • Next by Date: Re: Re: Using Select with arrays? (Relative newbie)
  • Previous by thread: Re: Axes in ShowGraph
  • Next by thread: Re: Axes in ShowGraph