On 16.08.2014 08:36, ayates wrote:
> Is it correct to use an edge property map of a graph with a graph view based
> on that graph? Specifically, I have an edge property of edge weights. I then
> filter the graph to the largest connected component, and then I want to run
> nested blockmodel on that largest connected component with the corresponding
> edge weights.
>
> The exact code I want to use is below. Is this correct, or do I need to also
> filter weight_prop so that it only has information about edges not filtered
> in the GraphView GL?
>
> Thank you so much!
>
>
>   EDGES, WEIGHT_V = get_edge_set(ADJ, WEIGHTS, N, K)
>   G = gt.Graph()
>   G.add_vertex(N)
>   G.add_edge_list(EDGES)
>   G.set_directed(False)
>   largest = graph_tool.topology.label_largest_component(G)
>   GL = gt.GraphView(G, vfilt=largest)
>   weight_prop = G.new_edge_property("int16_t")
>   weight_prop.a = WEIGHT_V
>   NBM = graph_tool.community.minimize_nested_blockmodel_dl(GL, verbose=True,
> epsilon=E, eweight=weight_prop)

This will work in many cases, but is not a good idea, since the property
map created with the original graph has no information on the
filtering. This is often not an issue, since the edge and vertex indexes
are the same in both graphs, and thus the property mapping works as
expected. But some algorithms expect the length of the array returned by
the ".fa" attribute to match the number of vertices / edges which are
not filtered.

In the example above, you could have done simply

   weight_prop = GL.new_edge_property("int16_t")

to avoid any problems.

Best,
Tiago

-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to