[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Inconsistency problems with large 19 million edges graph (p
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Inconsistency problems with large 19 million edges graph (proper email) |
Date: |
Sun, 5 Apr 2015 21:59:11 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi,
I'm pretty sure that the identifiers that you use in your graph are stored in
the "name" vertex attribute and the integer IDs in igraph are assigned
arbitrarily (since both Graph.Read_Ncol and Graph.TupleList accepts arbitrary
names as vertex identifiers, not only integers). Since the vertex IDs in your
file seem to be integers from zero to |V|-1, use Graph.Read_Edgelist -- this
will use the integer IDs from your file as is, and the edge lookups by ID will
behave as expected.
T.
On 04/05, Stefano Scerra wrote:
> (Sorry for accidentally double posting)
> Hello,
> I'm having a really strange problem with the library and I was hoping to
> get some advice.
>
> After loading a large 19 million edges graph, the library returns an
> inconsistent edge list.
> More precisely, nonexistent edges appear in the graph's edge sequence.
>
> I try to load the graph in two different ways, by using Graph.Read_Ncol,
> and by manually reading the edgelist and then using Graph.TupleList. In
> both cases, iterating on the graph's edge sequence (the es attribute)
> yields inconsistent results: for instance, the nonexisting edge 10->11 is
> returned.
>
> I'm using igraph 0.7.1-4 on Python 3.4.3 64 bit on Windows 7 SP1 64 bit
> Link to the graph:
> https://drive.google.com/file/d/0B0afrBfsijreOS1BZkVfdE10TlE/view?usp=sharing
>
> Here's the code:
>
> from igraph import Graph
> import csv
> import timeit
>
> def create_graph(file_graph):
> # load graph using Graph.Read_Ncol
> with open(file_graph, "r") as in_file:
> g = Graph.Read_Ncol(in_file, weights=False, directed=True)
> return g
>
> def create_graph2(file_graph):
> # load graph using Graph.TupleList
> edges = []
> with open(file_graph, "r") as in_file:
> reader = csv.reader(in_file, delimiter=" ")
> i = 0
> for row in reader:
> if row:
> edges.append([int(row[0]), int(row[1])])
> i += 1
> if i % 100000 == 0: print(i)
> return Graph.TupleList(edges=edges, directed=True)
>
>
> def generate_weighted_graph(input, output):
> g = create_graph2(input)
> print("ecount:", g.ecount(), "vcount:", g.vcount())
> with open(output, "w") as output_file:
> writer = csv.writer(output_file, delimiter=" ")
> for e in g.es:
> i, j = e.source, e.target
> writer.writerow([i, j])
>
> if __name__ == "__main__":
> generate_weighted_graph("C:/datasets/network",
> "C:/datasets/network_weighted")
>
>
> Could this possibly be a bug?
> Any help would be appreciated, thank you!
> Stefano
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
--
T.