[Top][All Lists]

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

[igraph] labelling vertices using python

From: venura.2.mendis
Subject: [igraph] labelling vertices using python
Date: Tue, 15 Jul 2008 11:55:25 +0100

Hello everybody! This is my first message to the list

Sorry if this is quite a straightforward problem, Ive just started using
igraph and this is essentially my first python programme so I might well
be doing something very silly.

Ive created a graph and added vertices and edges ok (atleast the graph
summary and plot indicates things are ok,

          g = igraph.Graph(directed=False)
        id2vIndexDict = dict()
        for vertice in nodeList:
            g.vs[count]["id"]= vertice[0]
            g.vs[count]["label"]= str(vertice[1])

            count= count+1
        for edge in edgeList:
            igraghEdge = (id2vIndexDict[edge[0]],id2vIndexDict[edge[1]])

nodeList is an object that I have generated from a database 0 index is a
unique ID and index 1 is a label. I'd like to label the vertices I
create with this label. This all seems to be ok and when I plot the
graph without labels everything is fine (igraph.plot(g, "g.png",
vertex_label=None). However with labels I get the following errors,
Traceback (most recent call last):
  File "D:/python/workspace/src\SQLGraph.py", line 137, in testgetiGraph
    igraph.plot(dendo, "dendo.png")
  File "C:\Python25\lib\site-packages\igraph\drawing.py", line 695, in
    if isinstance(target, basestring): result.save()
  File "C:\Python25\lib\site-packages\igraph\drawing.py", line 367, in
    if self._is_dirty: self.redraw()
  File "C:\Python25\lib\site-packages\igraph\drawing.py", line 342, in
    plotter(ctx, bbox, palette, *args, **kwds)
  File "C:\Python25\lib\site-packages\igraph\clustering.py", line 719,
in __plot__
    result = Dendrogram.__plot__(self, context, bbox, palette, *args,
  File "C:\Python25\lib\site-packages\igraph\clustering.py", line 539,
in __plot__
    for idx in xrange(self._n)]
  File "C:\Python25\lib\site-packages\igraph\clustering.py", line 488,
in _item_box_size
    xb, yb, w, h, xa, ya = context.text_extents(self._names[idx])
TypeError: Context.text_extents() argument must be a string or unicode

I tried setting the g.vs[count]["label"]= "test string" just to make
sure nothing weird with object getting dereference etc. I get the same
error. Also when I don't set the attribute label at all the plot works
ok and the vertices are labelled by index. I presume I'm not setting the
attributes correctly. Ive followed instructions at
which seems to make lots of sense but I guess am not doing something. 
Id appreciate any help/comments

British Telecommunications plc
Registered office: 81 Newgate Street London EC1A 7AJ
Registered in England no. 1800000 
This electronic message contains information from British
Telecommunications plc which may be privileged or confidential. The
information is intended to be for the use of the individual(s) or entity
named above. If you are not the intended recipient be aware that any
disclosure, copying, distribution or use of the contents of this
information is prohibited. If you have received this electronic message
in error, please notify us by telephone or email (to the numbers or
address above) immediately.
Activity and use of the British Telecommunications plc email system is
monitored to secure its effective operation and for other lawful
business purposes. Communications using this system will also be
monitored and may be recorded to secure effective operation and for
other lawful business purposes.

reply via email to

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