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: Tamás Nepusz
Subject: Re: [igraph] Loading graph from files
Date: Fri, 15 Nov 2013 20:02:38 +0100

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.

reply via email to

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