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 :) -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
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, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Hi, I'm trying to use centrality functions but I have a problem with trust_transitivity function. I'm loading my own graph using g = load_graph("graph1.dot") inisted of gt.random_graph(100, lambda: (poisson(3), poisson(3))). however, the returned of
t = gt.trust_transitivity(g, trust, source=g.vertex(2)) print t.a [ 0. 0. 1. ..., 0. 0. 0.]
and the returned of
t = gt.trust_transitivity(g, trust, *source=None, target=None*) print t.a
None seems that deg_sampler of random_graph function (i.e., lambda: (poisson(3), poisson(3)) ) is required to my loaded graph how do I solve this and let the trust_transitivity function works with the loaded graph? Best regards, Tamo -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 08/14/2011 08:53 AM, tamo wrote:
t = gt.trust_transitivity(g, trust, *source=None, target=None*) print t.a
None
seems that deg_sampler of random_graph function (i.e., lambda: (poisson(3), poisson(3)) ) is required to my loaded graph how do I solve this and let the trust_transitivity function works with the loaded graph?
Everything is working as it is supposed to. The difference is that if you pass source=None and target=None, the trust value between _all pair_ of vertices is returned. This means that the value type of the property map is a _vector_ instead of a scalar, so it cannot be accessed by the ".a" attribute. You have to use vertex descriptors, v = g.vertex(10) print t[v] Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Graph1.dot thanks for the quick reply. I have this simple code to use the function
g = load_graph("Graph1.dot") trust = g.new_edge_property("double") trust.a = random(g.num_edges()) t = gt.trust_transitivity(g, trust, source=g.vertex(2), target=None) print t.a
I was expecting to get some values same as the documentation example, so could you please explain to me why do I got the following results? [ 0. 0. 1. ..., 0. 0. 0.] Thank you P.S attached file is the graph I used to run this code -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 08/14/2011 05:37 PM, tamo wrote:
I was expecting to get some values same as the documentation example, so could you please explain to me why do I got the following results? [ 0. 0. 1. ..., 0. 0. 0.]
Why do you expect to get the same values as in the documentation for a different graph? I checked your graph, and it is undirected. Trust transitivity is only properly defined for directed graphs. Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
tamo -
Tiago de Paula Peixoto