[Top][All Lists]

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

Re: [igraph] What is the max value of a node id?

From: Tam??s Nepusz
Subject: Re: [igraph] What is the max value of a node id?
Date: Thu, 25 Apr 2013 21:58:38 +0200

> the parameter of igraph_add_vertices is for the count of nodes to add, but 
> not the node id.
Yup, that's why I mentioned this in my email.

> It seems that there is not a function by which adding a single node by its ID?
There is no need for such a function since igraph vertex IDs are always within 
the range [0; N-1], where N is the number of nodes.

> there is add_vertex() in python package, and if g.add_vertex(4294967296), the 
> number will be the Name of the node.
That's a completely different story. When you do that with the Python 
interface, the number you specify will be assigned to the "name" attribute of 
the vertex. The vertex will still receive the next available numeric ID, but 
this numeric ID will have no relation to the name that you specified.

If you want to use vertex attributes in the C interface, take a look at the 
documentation of the attribute handler interface in the C layer:


Note that the pure C igraph functions will still need the numeric vertex IDs, 
not the names you assign. You will have to look up the igraph ID of a vertex 
based on its name if you want to call a C function directly and you only know 
the name of the vertex and not its ID.

> BTW, I found that by calling g.add_vertex() in python, the Name of the node 
> can be very large number, even larger than 64 bits, why is that?
Because attributes in the Python interface can be arbitrary objects. If you 
specify a number that is larger than 2**64, Python converts it to an object of 
type "long" (which is Python's built-in type for numbers that do not fit within 
the usual integer range), and assigns this object as the value of the "name" 
attribute for that vertex.


reply via email to

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