28 Jul 2011 06:16

### elaboration please: remove_vertex_if&find_vertex

Hi,

Thank you again for this great library.

First, could you please describe more details about using remove_vertex_if
and find_vertex?
and how to deal with the returned of those functions?

also, I have a simulation  scenario where I have to remove nodes with the 10
% highest degrees. thus, I tried to use the following code as initial
attempt

*prop =  gt.find_vertex(g,"total",6)
gv = gt.GraphView(g, vfilt=prop, efilt=None, directed=False, reversed=False)
*

but it shows me the following error

Traceback (most recent call last):
File "test-failure.py", line 57, in <module>
gv = gt.GraphView(g, vfilt=gt.find_vertex(g,"total",6), efilt=None,
directed=False, reversed=False)
File "/usr/local/lib/python2.6/dist-packages/graph_tool/__init__.py", line
1525, in __init__
vmap[v] = vfilt(v)
TypeError: 'list' object is not callable

any help to do my scenario would be greatly appreciated

Thank you in advance :)
(Continue reading)

28 Jul 2011 09:35

### Re: elaboration please: remove_vertex_if&find_vertex

On 07/28/2011 06:16 AM, tamo wrote:
> First, could you please describe more details about using remove_vertex_if
> and find_vertex?
> and how to deal with the returned of those functions?

The function find_vertex() returns a list of vertices which match the
given property. The function remove_vertex_if() takes a _function_ as a
parameter. This function is called for each vertex in the graph. If the
returned value is 'True' for a given vertex, it is removed.

> also, I have a simulation  scenario where I have to remove nodes with
the 10
> % highest degrees. thus, I tried to use the following code as initial
> attempt
>
> *prop =  gt.find_vertex(g,"total",6)
> gv = gt.GraphView(g, vfilt=prop, efilt=None, directed=False,
reversed=False)
> *

In this code, 'prop' is not a property map, it is a list of
vertices. The 'vfilt' parameter expects either a property map or a
function.

If you want to filter out all vertices which have an out-degree larger
than 6, yo can do something like:

gv = gt.GraphView(g, vfilt=lambda v: v.out_degree() <= 6)

Cheers,
(Continue reading)

29 Jul 2011 01:51

### Re: Newbie issues

Hi,

I had not noticed this message, since it did no go through the mailing list
for some reason.

If the .deb packages don't work for you, I'm afraid you will have to compile
from source.

The CDE package is a bit outdated... It is only intended to give a "taste"
of the real thing.

Cheers,
Tiago

-----
--
Tiago de Paula Peixoto &lt;tiago <at> skewed.de&gt;
--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Newbie-issues-tp3162354p3208271.html
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.

Gmane