Message Boards Message Boards

Visualize imported data in a GraphPlot?

ReinstallJava[JVMArguments -> "-Xmx6012m"];
SetDirectory["C:\USERS\\DENCH\DROPBOX\SHARED DOCUMENTS\F MATHEMATICA"]
xx = Import["MATRIX_TEST_DATA_APR_27.xlsx"];
(*MatrixForm[xx];*)
List[xx]
GraphPlot[xx, Method -> "Automatic"]

{{{{1., 1., 1., 1., 1., 1., 0., 3., 1., 3.}, {0., 1., 1., 0., 2., 1., 
    1., 2., 0., 2.}, {3., 2., 0., 3., 1., 1., 1., 0., 0., 3.}, {1., 
    0., 0., 2., 3., 1., 0., 3., 2., 2.}, {3., 2., 3., 2., 9., 1., 2., 
    1., 3., 9.}, {1., 1., 1., 1., 1., 1., 0., 3., 1., 3.}, {0., 1., 
    1., 0., 2., 1., 1., 2., 0., 2.}, {3., 2., 0., 3., 1., 1., 1., 0., 
    0., 3.}, {1., 0., 0., 2., 3., 1., 0., 3., 2., 2.}, {3., 2., 3., 
    2., 9., 1., 2., 1., 3., 9.}}}}
GraphPlot::grph: {{{1.,1.,1.,1.,1.,1.,0.,3.,1.,3.},{0.,1.,1.,0.,2.,1.,1.,2.,0.,2.},{3.,2.,0.,3.,1.,1.,1.,0.,0.,3.},{1.,0.,0.,2.,3.,1.,0.,3.,2.,2.},{3.,2.,3.,2.,9.,1.,2.,1.,3.,9.},{1.,1.,1.,1.,1.,1.,0.,3.,1.,3.},{0.,1.,1.,0.,2.,1.,1.,2.,0.,2.},{3.,2.,0.,3.,1.,1.,1.,0.,0.,3.},{1.,0.,0.,2.,3.,1.,0.,3.,2.,2.},{3.,2.,3.,2.,9.,1.,2.,1.,3.,9.}}} is not a valid graph. >>
Attachments:
POSTED BY: roger Dench
3 Replies

Try: An Elementary Introduction to the Wolfram Language by Stephen Wolfram, which is free and very recent.

Also I suggest using Graph instead of GraphPlot because the former is a computable data structure and the later is just graphics.

POSTED BY: Vitaliy Kaurov

Hi Jason Many thanks for your advice, which worked perfectly. Apologies for the delay in replying - I have been out of touch these last few days. My error was clearly elementary, but as a newcomer I find the syntax quite strange - coming from an early Fortran and Algol environment. Which of the blizzard of tutorials, guides etc would you recommend as being the most pragmatic for someone who has a background in such programming? Vielen Dank Roger Dench

POSTED BY: roger Dench

GraphPlot will work when given an AdjacencyMatrix, but if you look at the structure of yy then you see it isn't quite a matrix:

In[5]:= Dimensions[yy]

Out[5]= {1, 10, 10}

You can see that yy is a list of matrices, a list that contains only one matrix. Looking back at the code, when you type yy = Join[ xx ]; you aren't really changing xx:

In[6]:= xx == Join[xx]

Out[6]= True

Instead use Flatten,

yy = Flatten[xx, 1];
GraphPlot[yy]

Mathematica graphics

POSTED BY: Jason Biggs
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