[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [igraph] problem with vertices

**From**: |
Tamas Nepusz |

**Subject**: |
Re: [igraph] problem with vertices |

**Date**: |
Thu, 27 Aug 2009 13:38:13 +0100 |

**User-agent**: |
Mutt/1.5.17 (2007-11-01) |

Hi Figa,
>* after deleting a vertex in the graph, the vertex is still there.. how come?*
This is because vertices are always numbered from zero to N-1 if you
have N vertices. If you delete vertex I, then the vertices from vertex
I+1 will be renumbered so the range becomes continuous again. In
general, don't add new vertices or delete existing ones when you are
iterating over the vertices in a loop.
>* g is an undirected graph;*
>* *
>* 1) I delete all edges whose weight is less than a certain threshold:*
There's an easier way to do that:
g.es.select(weight_lt = threshold) selects the edges that have weight
under the given threshold. You can call g.delete_edges() directly on
this object:
g.delete_edges(g.es.select(weight_lt = threshold))
>* 2) then I look for the vertices with degree equal to zero:*
This can also be done with a similar trick:
g.vs.select(_degree = 0)
This gives you a VertexSeq that contains only the vertices with degree
zero. Then you can delete them straight away:
g.delete_vertices(g.vs.select(_degree = 0))
--
Tamas