igraph-help
[Top][All Lists]
Advanced

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

[igraph] Check for duplicate nodes when adding new nodes


From: Krishna Sandeep Reddy Dubba
Subject: [igraph] Check for duplicate nodes when adding new nodes
Date: Mon, 2 Jun 2014 15:09:06 +0100

Hi all,
Recently I was trying to use igraph for building a graph. I first started with networkx where I was adding nodes which have a name associated with them.  networkx nicely avoids duplicate nodes but igraph does not.

# Session with networkx graph
import networkx as nx
graph = nx.DiGraph()
graph.add_node('A')
graph.nodes()
Out[5]: ['A']

graph.add_node('A')
graph.nodes()
Out[7]: ['A']

So networkx does not allow duplicate nodes. This is not the case with igraph (igraph uses the attribute 'name' to store the node label, but does not do duplicate checking on this attribute). Because of this in my case, igraph is slower than networkx! Is there a way I can do the same thing in igraph as networkx without maintaining a separate datastructure checking in it if I have added it to the igraph before adding a node?

Thanks,
Krishna Dubba

 

reply via email to

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