Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: tab-delimited file to graph

  • To: mathgroup at
  • Subject: [mg69460] Re: tab-delimited file to graph
  • From: "Jens-Peer Kuska" <kuska at>
  • Date: Wed, 13 Sep 2006 04:02:04 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <ee64q5$7s4$>


load the package:

<< DiscreteMath`Combinatorica`

and read the table form of your graph:

gr = Rule @@@ ImportString["v1 v2\n
v2 v3\n
v3 v1\n
v1 v4", "Table"];

Make a list of ordered pairs

slst = Union[Cases[gr, _String, Infinity]];
gr = gr /. Thread[slst -> Table[i, {i, 

and the graph

FromOrderedPairs[{1 -> 2, 2 -> 3, 3 -> 1, 1 -> 4}]



<aitor69gonzalez at> schrieb im Newsbeitrag 
news:ee64q5$7s4$1 at
| Hello,
| I have a directed graph "mygraph" in a tab 
delimited file that looks
| like this:
| v1    v2
| v2    v3
| v3    v1
| v1    v4
| I would like to import this graph into 
mathematica, so that I can take
| advantage of the -DiscreteMath`Combinatorica`- 
functions. So far, I was
| only able to import it with 
Import["mygraph","TSV"] into a list of
| two-item lists. Now, I am stuck there. Can 
somebody help me to convert
| this list of two-item lists into a matrix or 
adjacency list of a
| directed graph?
| Thank you in advance,
| Aitor

  • Prev by Date: Re: Evaluating a Meijer G-function
  • Next by Date: oscillatory integrals
  • Previous by thread: Re: tab-delimited file to graph
  • Next by thread: Re: tab-delimited file to graph