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.


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

  • 2
    $\begingroup$ 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? $\endgroup$ Dec 15, 2013 at 22:27

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

  • $\begingroup$ +1, but I wonder how the OP missed the Graph[ ] docs $\endgroup$ Dec 15, 2013 at 22:59
  • $\begingroup$ 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. $\endgroup$ Dec 16, 2013 at 0:16
  • $\begingroup$ @Pétur Try list = DeleteDuplicates[Sort/@ list, Equal[#1, #2] &] instead $\endgroup$ Dec 16, 2013 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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