Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm new to Mathematica yet have coded a lot in MATLAB. Currently I'm working on a network simulation. My model is implemented in MATLAB, but I need to port it to Mathematica.

Here is my question:

Given a graph g and coordinates x and y for each node. I want to plot the network with nodes at the corresponding coordinates. How can this be done?

In case you are also used to MATLAB, there is the function gplot, which does the job. Is there a similar plotting function in Mathematica?

share|improve this question
    
Maybe it's a case for AdjacencyMatrix[]. Please take a look at this post. –  Rod Jun 18 '13 at 15:43
2  
Or GraphPlot, using VertexCoordinateRules to specifiy coordinates? (See Documentation Center) –  Pinguin Dirk Jun 18 '13 at 15:45
    
Out of curiosity, what are you simulating? Unfortunately neither Mathematica not MATLAB are great at simulations (they're too slow), but Mma is great for analysis and visualization. –  Szabolcs Jun 18 '13 at 16:00
    
The latter is the reason I'm switching to Mathematica. The model I'm working is of theoretical interest only: I want to see, whether there will be segregation in different types of dynamic networks. –  user8115 Jun 18 '13 at 16:16
    
@user8115 If you already have your simulation code in MATLAB and just want to do the analysis/visualization in Mathematica, you can consider using MATLink (shameless self promotion ;-) Note: MATLink has good support for sparse arrays, in case you represent graphs using those. –  Szabolcs Jun 18 '13 at 17:47
show 2 more comments

1 Answer

Here's an example:

Graph[{1, 2}, {1 <-> 2}, VertexCoordinates -> {{0, 0}, {1, 1}}]

Pass the vertex list, edge list, and VertexCoordinates -> vertexCoordinateList to Graph. The coordinate list is in the same order as the vertex list.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.