# How to draw a network from a dataset reporting the labels of nodes of every link?

I have a dataset in format .txt of a directed network, containing a matrix A of dimension m x 2, where each row gives the labels of two nodes showing a direct link.

For example, when the network has $4$ nodes, the matrix A could be

A = [1 2; 1 3; 2 1; 2 4; 3 2; 4 1; 4 2]


where the first row means that there is a link from 1 to 2, the second row means that there is a link from 1 to 3, etc.

Could you suggest me a way to draw the network specified by A in Mathematica?

-
Probably you can do: DirectedEdge @@@ Import["text.txt", "Data"] // Graph. Please take a look at all those symbols in documentation if there are doubts. – Kuba May 22 '14 at 11:20
I guess you're aware that your line of code is NOT valid in Mathematica. – Dr. belisarius May 22 '14 at 11:37

First you need to get a minimum involved in what you are planning to do and search for "network" inside Mathematica:

http://reference.wolfram.com/mathematica/guide/GraphsAndNetworks.html

Then you want to construct a Graph so you go to:

http://reference.wolfram.com/mathematica/guide/GraphConstruction.html

and see: Graph — construct a graph from vertices and edges:

http://reference.wolfram.com/mathematica/ref/Graph.html

where the first example is:

Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1}]


So hey! Why not giving the same structure to A:

A = {1 -> 2, 1 -> 3, 2 -> 1, 2 -> 4, 3 -> 2, 4 -> 1, 4 -> 2}
Graph[A]


Regarding the Import part (like Kuba suggested):

mat = First@ToExpression@Import["http://pastebin.com/raw.php?i=tVXqhVgD", "Data"]

{{1,2},{1,3},{2,1},{2,4},{3,2},{4,1},{4,2}}

Graph[DirectedEdge @@@ mat]

-