igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Loading graph from files


From: Ahmed Abdeen Hamed
Subject: Re: [igraph] Loading graph from files
Date: Fri, 15 Nov 2013 15:34:34 -0500

Thank you!

I am getting this error:

>>> g = igraph.Graph.DictList(edges=reader)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: DictList() takes at least 3 arguments (2 given)

Here is how my file looks like:

source,target
tums,zantac

Thanks again!

-Ahmed



On Fri, Nov 15, 2013 at 2:02 PM, Tamás Nepusz <address@hidden> wrote:
Hi, I think csv is not directly supported, although probably only 3
lines of code after you have the edge list.
CSV files can probably be read with Python’s csv.DictReader class (from the CSV module) combined with igraph.Graph.DictList():

import csv
import igraph

reader = csv.DictReader(open(“file.csv”), dialect=“excel”)
g = igraph.Graph.DictList(edges=reader)

This assumes that the CSV file contains column headers and the columns named “source” and “target” contain the source and target vertex names. If your columns are named differently, use the edge_foreign_keys=… keyword argument of Graph.DictList.

— 
T.

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

[Prev in Thread] Current Thread [Next in Thread]