tkplot fails for a large graphs in R

Bug #572559 reported by Solomon Messing
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
igraph
Fix Released
Medium
Gábor Csárdi

Bug Description

When I try to use tkplot to manually set layout positions, I get this error message:

Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"), class = "tclObj") :
  [tcl] expected integer but got "7.199999999999999 7.199999999999999 7.199999999999".

Here is the code necessary to reproduce the error:

================================================

# Load the "igraph" library
library("igraph")

# (1) Read in the data files, NA data objects coded as "na"
magact96 = read.delim("http://stanford.edu/~messing/mag_act96.txt", na.strings = "na")
magact97 = read.delim("http://stanford.edu/~messing/mag_act97.txt", na.strings = "na")
magact98 = read.delim("http://stanford.edu/~messing/mag_act98.txt", na.strings = "na")

################################################################
# (2) Create the attribute data.
magattrib = magact96[,1:4]

################################################################
#(3) Drop columns so we have a square incidence matrix for each year
g96 = as.matrix(magact96[,-(1:4)]); row.names(g96) = magact96$ID.
g97 = as.matrix(magact97[,-(1:4)]); row.names(g97) = magact97$ID.
g98 = as.matrix(magact98[,-(1:4)]); row.names(g98) = magact98$ID.

################################################################
# (4) Now produce single mode co-event matrices for each year
g96e = t(g96) %*% g96
g97e = t(g97) %*% g97
g98e = t(g98) %*% g98

i96e = graph.adjacency(g96e, mode = "undirected")

#Transforms graph so that multiple edges become an attribute ( E(g)$weight ) of each unique edge
E(i96e)$weight <- count.multiple(i96e)
i96e <- simplify(i96e)

# Now plot the first single mode co-event matrices
# Set vertex attributes, making sure to make them slightly transparent by
# altering the gamma via the rgb(r,g,b,gamma) function.

V(i96e)$label = V(i96e)$name
V(i96e)$label.color = rgb(0,0,.2,.8)
V(i96e)$label.cex = .6
V(i96e)$size = 6
V(i96e)$frame.color = NA
V(i96e)$color = rgb(0,0,1,.5)

# Set edge attributes
E(i96e)$color = rgb(.5,.5,0,.2)

# Scale edge width according to edge weight
E(i96e)$width = log(E(i96e)$weight)/2 +.5

tkplot(i96e)

======================================================

Thank you,

-Solomon Messing

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

OK, there a number of problems here:

1. tkplot does not support different label colors. In your example they are the same color, but the color is set for each vertex individually, and this is not supported. A workaround is to give the label color in the plot() call, or to set the default with igraph.par().

2. NA as frame color is not supported, either. Supply the same color here as for the vertices, to get rid of the frame.

3. label.cex cannot be different for different vertices, either. The same problem as for 'label.color'.

I will fix these, i.e. add support for them in the next version. Thanks for the report!

After running
i96e <- remove.vertex.attribute(i96e, "label.color")
i96e <- remove.vertex.attribute(i96e, "frame.color")
i96e <- remove.vertex.attribute(i96e, "label.cex")
tkplot() works, although it is quite slow.

Changed in igraph:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Gábor Csárdi (gabor.csardi)
Revision history for this message
Solomon Messing (solomon-messing) wrote : Re: [Bug 572559] Re: tkplot fails for a large graphs in R
Download full text (4.0 KiB)

Oh ok thank you. I want to hand-place certain nodes in the layout with
tkplot, so I can just set those graph attributes after I call
tkplot.getcoords and then output to PDF as a workaround for now,
correct?

Thank you,

-Solomon

On May 1, 2010, at 1:51 AM, Gábor Csárdi <email address hidden>
wrote:

> OK, there a number of problems here:
>
> 1. tkplot does not support different label colors. In your example
> they
> are the same color, but the color is set for each vertex individually,
> and this is not supported. A workaround is to give the label color in
> the plot() call, or to set the default with igraph.par().
>
> 2. NA as frame color is not supported, either. Supply the same color
> here as for the vertices, to get rid of the frame.
>
> 3. label.cex cannot be different for different vertices, either. The
> same problem as for 'label.color'.
>
> I will fix these, i.e. add support for them in the next version.
> Thanks
> for the report!
>
> After running
> i96e <- remove.vertex.attribute(i96e, "label.color")
> i96e <- remove.vertex.attribute(i96e, "frame.color")
> i96e <- remove.vertex.attribute(i96e, "label.cex")
> tkplot() works, although it is quite slow.
>
> ** Changed in: igraph
> Status: New => Confirmed
>
> ** Changed in: igraph
> Importance: Undecided => Medium
>
> ** Changed in: igraph
> Assignee: (unassigned) => Gábor Csárdi (gabor.csardi)
>
> --
> tkplot fails for a large graphs in R
> https://bugs.launchpad.net/bugs/572559
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in The igraph library: Confirmed
>
> Bug description:
> When I try to use tkplot to manually set layout positions, I get
> this error message:
>
> Error in structure(.External("dotTclObjv", objv, PACKAGE = "tcltk"),
> class = "tclObj") :
> [tcl] expected integer but got "7.199999999999999 7.199999999999999 7.199999999999
> ".
>
> Here is the code necessary to reproduce the error:
>
> ================================================
>
> # Load the "igraph" library
> library("igraph")
>
> # (1) Read in the data files, NA data objects coded as "na"
> magact96 = read.delim("http://stanford.edu/~messing/mag_act96.txt",
> na.strings = "na")
> magact97 = read.delim("http://stanford.edu/~messing/mag_act97.txt",
> na.strings = "na")
> magact98 = read.delim("http://stanford.edu/~messing/mag_act98.txt",
> na.strings = "na")
>
> ################################################################
> # (2) Create the attribute data.
> magattrib = magact96[,1:4]
>
> ################################################################
> #(3) Drop columns so we have a square incidence matrix for each year
> g96 = as.matrix(magact96[,-(1:4)]); row.names(g96) = magact96$ID.
> g97 = as.matrix(magact97[,-(1:4)]); row.names(g97) = magact97$ID.
> g98 = as.matrix(magact98[,-(1:4)]); row.names(g98) = magact98$ID.
>
> ################################################################
> # (4) Now produce single mode co-event matrices for each year
> g96e = t(g96) %*% g96
> g97e = t(g97) %*% g97
> g98e = t(g98) %*% g98
>
> i96e = graph.adjacency(g96e, mode = "undirected")
>
> #Transforms graph so that multiple...

Read more...

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

Yes, that works. This is actually the preferred method for creating plots, because the R graphical devices are a lot more flexible, they support more formats, etc.

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

I've solved issue 1 above in revisions #1913 (0.6-main) and #1620 (0.5-main).

Issues 2 and 3 are a bit more difficult.

Changed in igraph:
milestone: none → 0.6
Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

OK, issue 2 is solved by revision #2783 (0.6-main).

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

OK, fixed issue #3 in revision #2786 (0.6-main).

Changed in igraph:
status: Confirmed → Fix Released
Revision history for this message
Gábor Csárdi (gabor.csardi) wrote : Continue on github

The development of igraph has moved to github, so please do not comment on this bug here. You are of course welcome to comment on github, here:
https://github.com/igraph/igraph/issues/187

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers