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 have a list of pairs of numbers, representing connections between objects in the real world. Each number is the identifier of an object, there are gaps in the range from the smallest number to the largest number.

43,292
22,11
932,11
292,22
etc...

I need to visualise how all of the objects are related. I intended to create a graph representation of that network.

share|improve this question
2  
Just curious: Have you tried looking this up in the built-in documentation (F1 on Windows) and if so, what problems did you encounter there? –  Sjoerd C. de Vries Dec 15 '13 at 22:27
add comment

1 Answer 1

If you have a list

list = {{43, 292}, {22, 11}, {932, 11}, {292, 22}};

Then you can construct a Graph by

Graph[UndirectedEdge @@@ list, VertexLabels -> "Name"] 

enter image description here

share|improve this answer
    
+1, but I wonder how the OP missed the Graph[ ] docs –  belisarius Dec 15 '13 at 22:59
    
Graph::supp: Mixed graphs and multigraphs are not supported. >> .. I tried eliminate duplicates with list = DeleteDuplicates[list, Equal[#1, #2] &] before executing the command you gave. –  Pétur Dec 16 '13 at 0:16
    
@Pétur Try list = DeleteDuplicates[Sort/@ list, Equal[#1, #2] &] instead –  belisarius Dec 16 '13 at 3:57
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.