# How to construct a graph from a list of edges

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.

=================

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

=================

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”]

+1, but I wonder how the OP missed the Graph[ ] docs
– Dr. 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
– Dr. belisarius
Dec 16 ’13 at 3:57