igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Create a graph from an edgelist file(.txt) which is weighte


From: Tamas Nepusz
Subject: Re: [igraph] Create a graph from an edgelist file(.txt) which is weighted
Date: Wed, 17 Apr 2013 14:54:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

> How can I create the graph from this big weighted edgelist file?
1. Use igraph_read_graph_ncol -- the only catch is that the node IDs in
igraph will not match the ones in the file; the IDs from the file will be
stored in a vertex attribute named "name", and you will have to create a
mapping from the names in the file to the igraph IDs and/or use
igraph_permute_vertices.

2. Take a look at the source code of igraph_read_graph_edgelist and adapt it
to read the weights as well. Should not be complicated, you only need an
extra vector to read the weights into using igraph_vector_push_back(). The
source code of igraph_read_graph_edgelist is here:

https://github.com/igraph/igraph/blob/master/src/foreign.c#L78

-- 
T.



reply via email to

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