Message Boards Message Boards

0
|
4385 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Problem with PlanarGraphPlot And ConvexHull

Posted 10 years ago
I'm getting a lot of strange errors when using PlanarGraphPlot with a simple list of 11 points
 << ComputationalGeometry`;
 x = {{184978.59580704456`, 77909.66948289984`}, {184978.27815712072`,
     77909.76595227784`}, {184978.27082673783`,
     77909.74177736834`}, {184977.5543690799`,
     77909.95958192856`}, {184977.65873976916`,
     77910.2913545858`}, {184977.87393886593`,
     77910.32174601014`}, {184978.3127146399`,
     77911.75682671613`}, {184979.13720817852`,
     77911.37094455786`}, {184979.40459261995`,
    77911.34308556134`}, {184979.6157774594`,
    77912.04232488069`}, {184980.40222282038`, 77911.69604330455`}};
PlanarGraphPlot[x]
Errors I get are
 Mod::indet: Indeterminate expression Mod[-1,0] encountered. >>
 
 Part::partw: Part 1 of {} does not exist. >>
 
 Part::pspec: Part specification Indeterminate is neither a machine-sized integer nor a list of machine-sized integers. >>
 
 Part::pspec: Part specification {{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[8,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>
 
 Part::pspec: Part specification {{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[8,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

General::stop: Further output of Part::pspec will be suppressed during this calculation. >>

Part::partw: Part 1 of {} does not exist. >>

Set::shape: Lists {ComputationalGeometry`Private`merge$30945[[ComputationalGeometry`Private`l0$30945]],ComputationalGeometry`Private`merge$30945[[ComputationalGeometry`Private`r0$30945]]} and ComputationalGeometry`Private`insert[{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[{6,{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[8,1]]}]],6,{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,<<3>>,5},<<1>>,{},{7,10},{9,7,11},{10,7}}[[<<1>>]],2,3] are not the same shape. >>

Mod::indet: Indeterminate expression Mod[-1,0] encountered. >>

Part::partw: Part 1 of {} does not exist. >>

General::stop: Further output of Part::partw will be suppressed during this calculation. >>

Set::shape: Lists {ComputationalGeometry`Private`merge$33935[[ComputationalGeometry`Private`l0$33935]],ComputationalGeometry`Private`merge$33935[[ComputationalGeometry`Private`r0$33935]]} and ComputationalGeometry`Private`insert[{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[{6,{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[8,1]]}]],6,{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,<<3>>,5},<<1>>,{},{7,10},{9,7,11},{10,7}}[[<<1>>]],2,3] are not the same shape. >>

Mod::indet: Indeterminate expression Mod[-1,0] encountered. >>

General::stop: Further output of Mod::indet will be suppressed during this calculation. >>

Set::shape: Lists {ComputationalGeometry`Private`merge$35305[[ComputationalGeometry`Private`l0$35305]],ComputationalGeometry`Private`merge$35305[[ComputationalGeometry`Private`r0$35305]]} and ComputationalGeometry`Private`insert[{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[{6,{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,5,6,3,5},{11,10,9,4},{},{7,10},{9,7,11},{10,7}}[[8,1]]}]],6,{{4,2},{1,4,6},{6},{7,2,1},{6,6},{2,<<3>>,5},<<1>>,{},{7,10},{9,7,11},{10,7}}[[<<1>>]],2,3] are not the same shape. >>

General::stop: Further output of Set::shape will be suppressed during this calculation. >>

When I drop the last point I get the expected plot
PlanarGraphPlot@Drop[x, -1]
I've attached a file with the code.  My Mathematica version is 9.0.1 on Mac OS X

Thanks
Attachments:
POSTED BY: Kartik
6 Replies
Posted 10 years ago
It was due to floating point precision.  See discussion here
POSTED BY: Kartik
The set y seems to have a similiar problem you might investigate further, again Rationalize[] works

POSTED BY: Udo Krause
Posted 10 years ago
Also this set of points fails to give proper ConvexHull.  It fails silently without errors or warnings.  Using Mma 9.0.1 64-bit on Mac OSX
 y = {{1.8497859580704457`, 0.7790966948289985`}, {1.8497827815712071`,
     0.7790976595227784`}, {1.8497827082673783`,
    0.7790974177736835`}, {1.849775543690799`,
    0.7790995958192857`}, {1.8497765873976917`,
    0.779102913545858`}, {1.8497787393886593`,
    0.7791032174601015`}, {1.849783127146399`,
    0.7791175682671613`}, {1.8497913720817853`,
    0.7791137094455786`}, {1.8497940459261994`,
    0.7791134308556135`}, {1.849796157774594`,
   0.7791204232488069`}, {1.849804022228204`,
   0.7791169604330455`}, {1.849803552734635`,
   0.7791159289575218`}, {1.8498057134522492`,
   0.7791151852825192`}, {1.8498006729413692`,
   0.7790991813917657`}, {1.8498002121744468`,
   0.7790984699581178`}, {1.8497995890919037`,
   0.7790977401058187`}, {1.8497986151981813`,
   0.7790973602143807`}, {1.8497975924352397`,
   0.7790973993547065`}, {1.8497955957785752`,
   0.77909842160827`}, {1.8497951821355425`,
   0.7790997823117062`}, {1.8497944840038416`,
   0.779101624213374`}, {1.8497934996381435`,
   0.7791037516125543`}, {1.8497920021456453`,
   0.779106194441444`}, {1.849792775326504`,
   0.7791094914607818`}, {1.8497897908134828`,
   0.7791098506337076`}}
Graphics@Point@y[[ ConvexHull[y] ]]

Thanks for trying on windows Udo.  Sorting doesn't help on Mac OS X.
POSTED BY: Kartik
Sorting doesn't help on Mac OS X.

To clarify, please: Sort[] under Windows does help under the following circumstances only
  • load the ComputationalGeometry package
  • read in data set x
  • comment any data point from the set out and save the notebook
  • run PlanarGraphPlot with that reduced set x
  • reactivate the data point, thus restoring the set x to its original content
  • run PlanarGraphPlot[Sort], it works
If one loads ComputationalGeometry package, reads in the set x and runs directly PlanarGraphPlot[Sort] under Windows, it fails too, like under Mac. I've searched for hidden content in the notebook, but did not find some.
POSTED BY: Udo Krause
To clarify even more: there is a problem with pseudo collinearity within the set x, pointed out by
PlanarGraphPlot[Normalize/@x]

DelaunayTriangulation::collin: Points {{0.921589,0.388168},{0.921589,0.388167},{0.92159,0.388165},<<5>>,{0.921592,0.388159},{0.921592,0.388159},{0.921593,0.388158}} are collinear. >>
Knowing that one has to go to the last resort
PlanarGraphPlot[MapIndexed[Rationalize[#, 0] &, x, {2}]]
and that works without any special fiddling by the user.
POSTED BY: Udo Krause
Me too, the error disappears after commenting any point out, not just the last one. This works (Windows 7 64 Bit Mma 9.0.1) with all points
PlanarGraphPlot[Sort[x]]
POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract