
From:  Christian Jost 
Subject:  [igraph] plotting planar graphs with igraph? 
Date:  Wed, 8 Dec 2010 10:07:27 +0100 
Dear all, I currently struggle with igraph to make it do things it doesn't seem to be designed to do. First, my networks are actually planar graphs representing tunneling networks (dug by ants in 2D sand disks) that I have digitised in Pajek format (see example below, vertex 1 is the origin of the digging activity). I can read these graphs without problem with read.graph, but when it comes to manipulating them I encounter problems. For the moment I am stuck with two problems. a) plot the graph with the correct x and y coordinates (specifically, I tried to write a function doing that, successfully plotting vertices at the x,y coordinates, but I cannot extract the vertex numbers of each edge provided by E(g) and therefore cannot add the edges; but there may be a simpler way to draw such a graph). b) I have to remove the degree2 nodes in order to get a simpler network with only the bifurcations and the endpoints. I use degree(g) to detect the nodes with degree 2, but when I feed their identities to "delete.vertices()" I get as a result many disconnected vertices. This function does not seem to reconnect the neighbour vertices after removing the degree 2 node. Is this normal behaviour? How could I keep the network connected? The final goal will be to order the bifurcations (topological distance from first vertice/origin) and compute the geometrical distances between them and the origin (where I will need again the degree2 vertices to compute the original tunnel length). gCC = read.graph(file="testNetwork.net", format="pajek") is.connected(gCC) gCCtree = minimum.spanning.tree(gCC) tmpDeg = degree(gCCtree) tmpDeg2 = which(tmpDeg==2) if (tmpDeg[1]==1) { # conserve node 0, the origin, by all means tmpDeg2 = tmpDeg2[2:length(tmpDeg2)] } gCCtree2 = delete.vertices(gCCtree,tmpDeg21) degree(gCCtree2) which gives me 0degree vertices. Any help/clarification would be most welcome. Thanks in advance, Christian. *Vertices 27 1 "'node'" 0.0699918 0.0010586 1 2 "'node'" 0.0737461 0.0174669 1 3 "'node'" 0.0651648 0.010586 1 4 "'node'" 0.0678464 0.0153497 1 5 "'node'" 0.0576561 0.0174669 1 6 "'node'" 0.0469294 0.0142911 1 7 "'node'" 0.043175 0.0206427 1 8 "'node'" 0.0394207 0.0174669 1 9 "'node'" 0.0404933 0.00476371 1 10 "'node'" 0.0635558 0.0296408 1 11 "'node'" 0.0871545 0.00793951 1 12 "'node'" 0.0839365 0.0031758 1 13 "'node'" 0.0769641 0.0111153 1 14 "'node'" 0.0796458 0.0174669 1 15 "'node'" 0.0313756 0.0100567 1 16 "'node'" 0.0120675 0.010586 1 17 "'node'" 0.0265486 0.026465 1 18 "'node'" 0.0292303 0.015879 1 19 "'node'" 0.0227943 0.021172 1 20 "'node'" 0.0378117 0.0476371 1 21 "'node'" 0.0748188 0.0243478 1 22 "'node'" 0.0962722 0.0111153 1 23 "'node'" 0.0957359 0.0015879 1 24 "'node'" 0.0925179 0.0164083 1 25 "'node'" 0.0581924 0.0407561 1 26 "'node'" 0.0640921 0.0497543 1 27 "'node'" 0.046393 0.0524008 1 *Edges 1 2 0.0189021 1 3 0.0126054 1 6 0.0277036 1 9 0.0297302 1 10 0.0292979 1 11 0.0193785 1 12 0.0141045 1 13 0.0122373 2 21 0.00696402 3 4 0.00546665 3 5 0.0101847 6 7 0.00737821 6 8 0.00815268 7 20 0.027522 8 18 0.0103133 9 15 0.0105427 10 25 0.0123416 11 22 0.00965496 12 23 0.0127247 13 14 0.00689451 13 24 0.0164297 15 16 0.0193153 15 17 0.0171036 18 19 0.00833297 25 26 0.0107598 25 27 0.0165778 
[Prev in Thread]  Current Thread  [Next in Thread] 