Hi all,
I was wondering what's the rationale behind not returning a reference
object to newly created vertices and edges in Python (or at least an
index)?
Example:
import igraph as ig
graph = ig.Graph()
v1 = graph.add_vertex()
.
.
.
v2 = graph.add_vertex()
e1 = graph.add_edge(v1.index, v2.index)
If I am reading a large graph file (special-format, let's assume), checking
if a vertex (or an edge between two vertices) has been already created is
really problematic.
The only way to do so is to maintain a Python dictionary for vertices
{"name": igraph.Vertex object}, where after creating a new vertex, say with
name="foo", one has to call graph.vs.find(name="foo") to get the
igraph.Vertex object. I am assuming that "find" takes O(n) time where n is
number of nodes. So this is an O(n*n) time operation.
As for edges, assuming we have the vertices dictionary, we still need to
check whether an edge was created (as one might read duplicate adjacency
lists or directional ones). The only way to check for this is to use
graph.es.find(...), which I assume takes O(m) where m is the number of
edges. iGraph does allow multiple edges from the same source vertex to be
established with the same target vertex. So this is a concern.
What do you think?
Cheers,
Yazan
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help